Package org.jboss.ws.core.soap

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


              "  <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

*/
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

      }
   }

   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

         "<env:Body>" +
         "<ns2:Foo xmlns:ns2='firstNS'/>" +
         "</env:Body>" +
         "</env:Envelope>";
     
      MessageFactoryImpl factory = new MessageFactoryImpl();
      factory.setStyle(Style.DOCUMENT);
      SOAPMessage soapMessage = factory.createMessage(null, new ByteArrayInputStream(envStr.getBytes()));
     
      SOAPContentElement sce = getSOAPContentElement(soapMessage);
     
      //force transition to XML_VALID and set an equivalent XMLFragment (but having a new ns declaration that would overwrite the one in the original fragment)
      sce.setXMLFragment(new XMLFragment("<Foo xmlns='firstNS' xmlns:ns2='secondNs'/>"));
     
      SOAPBody soapBody = soapMessage.getSOAPBody();
      //force transition to DOM_VALID
      soapBody.getFirstChild().getChildNodes();
     
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      soapMessage.writeTo(baos);
     
      soapMessage = factory.createMessage(null, new ByteArrayInputStream(baos.toByteArray()));
      Node foo = soapMessage.getSOAPBody().getFirstChild();
      assertEquals("firstNS", foo.getNamespaceURI());
   }
View Full Code Here

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

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

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

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

      EndpointInvocation epInv = binding.unbindRequestMessage(opMetaData, reqMessage);
View Full Code Here

      paramMetaData.setIndex(1);
      paramMetaData.setInHeader(true);

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

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

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

      CommonBindingProvider bindingProvider = new CommonBindingProvider(CommonSOAPBinding.SOAP12HTTP_BINDING, Type.JAXRPC);
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.