Package org.jboss.ws.core.soap

Examples of org.jboss.ws.core.soap.MessageFactoryImpl


      CommonBindingProvider bindingProvider = new CommonBindingProvider(CommonSOAPBinding.SOAP12HTTP_BINDING, Type.JAXRPC);
      CommonBinding binding = (CommonBinding)bindingProvider.getCommonBinding();

      ByteArrayInputStream inputStream = new ByteArrayInputStream(resEnvelopeWithFault.getBytes());

      MessageFactory factory = new MessageFactoryImpl();
      SOAPMessageImpl resMessage = (SOAPMessageImpl)factory.createMessage(null, inputStream);

      CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
      msgContext.setSOAPMessage(resMessage);

      try
View Full Code Here


*/
public class GenericAttachmentTestCase extends JBossWSTest
{
   public void testEncodingDecoding() throws Exception
   {
      MessageFactoryImpl factory = new MessageFactoryImpl();
      SOAPMessage msg1 = factory.createMessage();
      AttachmentPart attachment1 = msg1.createAttachmentPart();
      attachment1.setContent("this is a test", "text/plain; charset=UTF-8");
      attachment1.setContentId("<attachment1@test.ws.jboss.org>");
      msg1.addAttachmentPart(attachment1);

      BufferedImage img = new BufferedImage(2, 2, 1);
      img.setRGB(0, 0, 5);
      img.setRGB(0, 1, 6);
      img.setRGB(1, 0, 101);
      img.setRGB(1, 1, 102);
      AttachmentPart attachment2 = msg1.createAttachmentPart();
      attachment2.setContent(img, "image/png");
      attachment2.setContentId("<attachment2@test.ws.jboss.org>");
      msg1.addAttachmentPart(attachment2);

      if (msg1.saveRequired())
         msg1.saveChanges();

      String type = msg1.getMimeHeaders().getHeader(MimeConstants.CONTENT_TYPE)[0];
      File file = File.createTempFile("JBossWSAttachmentTest", ".dat");
      file.deleteOnExit();

      FileOutputStream os = new FileOutputStream(file);
      msg1.writeTo(os);
      os.flush();
      os.close();

      FileInputStream is = new FileInputStream(file);
      MimeHeaders headers = new MimeHeaders();
      headers.addHeader(MimeConstants.CONTENT_TYPE, type);

      SOAPMessage msg2 = new MessageFactoryImpl().createMessage(headers, is);

      // Verify SOAP body is the same
      SOAPEnvelope expEnv = msg1.getSOAPPart().getEnvelope();
      SOAPEnvelope wasEnv = msg2.getSOAPPart().getEnvelope();
      assertEquals(expEnv, wasEnv);
View Full Code Here

      String type = reqMessage.getMimeHeaders().getHeader(MimeConstants.CONTENT_TYPE)[0];

      MimeHeaders headers = new MimeHeaders();
      headers.addHeader(MimeConstants.CONTENT_TYPE, type);
      SOAPMessageImpl msg2 = (SOAPMessageImpl)new MessageFactoryImpl().createMessage(headers, in);

      epInv = binding.unbindRequestMessage(opMetaData, msg2);

      assertEquals(epInv.getRequestParamValue(new QName("String_1")).toString(), "Hello World!");
      assertEquals(epInv.getRequestParamValue(new QName("foo")).toString(), "hi");

      epInv.setReturnValue("test");

      SOAPMessage responseMessage = (SOAPMessage)binding.bindResponseMessage(opMetaData, epInv);

      stream = new ByteArrayOutputStream();
      responseMessage.writeTo(stream);

      in = new ByteArrayInputStream(stream.toByteArray());

      type = responseMessage.getMimeHeaders().getHeader(MimeConstants.CONTENT_TYPE)[0];

      headers = new MimeHeaders();
      headers.addHeader(MimeConstants.CONTENT_TYPE, type);
      SOAPMessageImpl msg3 = (SOAPMessageImpl)new MessageFactoryImpl().createMessage(headers, in);

      binding.unbindResponseMessage(opMetaData, msg3, epInv, null);

      assertEquals("test", epInv.getReturnValue());
   }
View Full Code Here

      assertEquals("test", epInv.getReturnValue());
   }

   public void testMimeMatchingAttachments() throws Exception
   {
      MessageFactoryImpl factory = new MessageFactoryImpl();
      SOAPMessage msg1 = factory.createMessage();

      AttachmentPart part1 = msg1.createAttachmentPart();
      AttachmentPart part2 = msg1.createAttachmentPart();
      AttachmentPart part3 = msg1.createAttachmentPart();
      AttachmentPart part4 = msg1.createAttachmentPart();
View Full Code Here

public class SOAPHeaderTestCase extends JBossWSTest
{

   public void testAddHeaderElement() throws Exception
   {
      MessageFactory factory = new MessageFactoryImpl();
      SOAPMessage soapMessage = factory.createMessage();
      SOAPEnvelope soapEnv = soapMessage.getSOAPPart().getEnvelope();
      SOAPHeader soapHeader = soapEnv.getHeader();

      // Test if we see the right NS URI for the env prefix
      assertEquals(Constants.NS_SOAP11_ENV, soapHeader.getNamespaceURI("env"));
View Full Code Here

              "  <ns2:Bar xmlns:ns2='http://org.jboss.ws/header2'>SomeOtherValue</ns2:Bar>" +
              " </env:Header>" +
              " <env:Body/>" +
              "</env:Envelope>";

      MessageFactory factory = new MessageFactoryImpl();
      SOAPMessage soapMessage = factory.createMessage(null, new ByteArrayInputStream(envStr.getBytes()));
      SOAPEnvelope soapEnv = soapMessage.getSOAPPart().getEnvelope();
      SOAPHeader soapHeader = soapEnv.getHeader();

      Iterator it = soapHeader.examineAllHeaderElements();
      SOAPHeaderElement foo = (SOAPHeaderElement)it.next();
View Full Code Here

              "  <ns2:Bar xmlns:ns2='http://org.jboss.ws/header2' env:actor='BradPitt'>SomeOtherValue</ns2:Bar>" +
              " </env:Header>" +
              " <env:Body/>" +
              "</env:Envelope>";

      MessageFactory factory = new MessageFactoryImpl();
      SOAPMessage soapMessage = factory.createMessage(null, new ByteArrayInputStream(envStr.getBytes()));
      SOAPEnvelope soapEnv = soapMessage.getSOAPPart().getEnvelope();
      SOAPHeader soapHeader = soapEnv.getHeader();

      Iterator it = soapHeader.examineHeaderElements("BradPitt");
      SOAPHeaderElement bar = (SOAPHeaderElement)it.next();
View Full Code Here

              "  <ns2:Bar xmlns:ns2='http://org.jboss.ws/header2' env:actor='BradPitt' env:mustUnderstand='1'>SomeOtherValue</ns2:Bar>" +
              " </env:Header>" +
              " <env:Body/>" +
              "</env:Envelope>";

      MessageFactory factory = new MessageFactoryImpl();
      SOAPMessage soapMessage = factory.createMessage(null, new ByteArrayInputStream(envStr.getBytes()));
      SOAPEnvelope soapEnv = soapMessage.getSOAPPart().getEnvelope();
      SOAPHeader soapHeader = soapEnv.getHeader();

      Iterator it = soapHeader.examineMustUnderstandHeaderElements("BradPitt");
      SOAPHeaderElement bar = (SOAPHeaderElement)it.next();
View Full Code Here

              "  <ns2:Bar xmlns:ns2='http://org.jboss.ws/header2'>SomeOtherValue</ns2:Bar>" +
              " </env:Header>" +
              " <env:Body/>" +
              "</env:Envelope>";

      MessageFactory factory = new MessageFactoryImpl();
      SOAPMessage soapMessage = factory.createMessage(null, new ByteArrayInputStream(envStr.getBytes()));
      SOAPEnvelope soapEnv = soapMessage.getSOAPPart().getEnvelope();
      SOAPHeader soapHeader = soapEnv.getHeader();

      Iterator it = soapHeader.extractAllHeaderElements();
      SOAPHeaderElement foo = (SOAPHeaderElement)it.next();
View Full Code Here

              "  <ns2:Bar xmlns:ns2='http://org.jboss.ws/header2' env:actor='BradPitt'>SomeOtherValue</ns2:Bar>" +
              " </env:Header>" +
              " <env:Body/>" +
              "</env:Envelope>";

      MessageFactory factory = new MessageFactoryImpl();
      SOAPMessage soapMessage = factory.createMessage(null, new ByteArrayInputStream(envStr.getBytes()));
      SOAPEnvelope soapEnv = soapMessage.getSOAPPart().getEnvelope();
      SOAPHeader soapHeader = soapEnv.getHeader();

      Iterator it = soapHeader.extractHeaderElements("BradPitt");
      SOAPHeaderElement bar = (SOAPHeaderElement)it.next();
View Full Code Here

TOP

Related Classes of org.jboss.ws.core.soap.MessageFactoryImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.