Search in sources :

Example 21 with SOAPMessage

use of jakarta.xml.soap.SOAPMessage in project metro-jax-ws by eclipse-ee4j.

the class SAAJFactoryTest method testDuplicatedContentID.

public void testDuplicatedContentID() throws Exception {
    String ctype = "multipart/related; boundary=MIME_Boundary; " + "start=\"<6232425701115978772--54bee05.140acdf4f8a.-7f3f>\"; " + "type=\"text/xml\"; start-info=\"text/xml\"";
    InputStream is = getClass().getClassLoader().getResourceAsStream("etc/bug17367334InputMsg.txt");
    MessageContextFactory mcf = MessageContextFactory.createFactory();
    Packet packet = (Packet) mcf.createContext(is, ctype);
    Message message = packet.getInternalMessage();
    SAAJFactory factory = new SAAJFactory();
    SOAPMessage saajMessage = factory.readAsSOAPMessage(SOAPVersion.SOAP_11, message);
    AttachmentPart ap = (AttachmentPart) saajMessage.getAttachments().next();
    Iterator it = ap.getAllMimeHeaders();
    int countContentID = 0;
    while (it.hasNext()) {
        MimeHeader mh = (MimeHeader) it.next();
        if ("Content-Id".equalsIgnoreCase(mh.getName())) {
            countContentID++;
        }
    }
    assertEquals("More than one Content-Id", 1, countContentID);
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) Message(com.sun.xml.ws.api.message.Message) SOAPMessage(jakarta.xml.soap.SOAPMessage) StreamMessage(com.sun.xml.ws.message.stream.StreamMessage) MessageContextFactory(com.oracle.webservices.api.message.MessageContextFactory) SAAJFactory(com.sun.xml.ws.api.message.saaj.SAAJFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) MimeHeader(jakarta.xml.soap.MimeHeader) Iterator(java.util.Iterator) AttachmentPart(jakarta.xml.soap.AttachmentPart) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Example 22 with SOAPMessage

use of jakarta.xml.soap.SOAPMessage in project metro-jax-ws by eclipse-ee4j.

the class WrapperNSTest method testWrapperNS.

public void testWrapperNS() throws Exception {
    Class<?> sei = MyHelloRPC.class;
    DatabindingFactory fac = DatabindingFactory.newInstance();
    Databinding.Builder b = fac.createBuilder(sei, null);
    DatabindingModeFeature dbf = new DatabindingModeFeature("eclipselink.jaxb");
    WebServiceFeature[] f = { dbf };
    b.feature(f);
    b.serviceName(new QName("http://echo.org/", "helloService"));
    b.portName(new QName("http://echo.org/", "helloPort"));
    Databinding db = b.build();
    {
        Method method = findMethod(sei, "echoString");
        Object[] args = { "test" };
        JavaCallInfo call = db.createJavaCallInfo(method, args);
        MessageContext mc = db.serializeRequest(call);
        SOAPMessage msg = mc.getSOAPMessage();
        // System.out.println("------------------ eclipselink");
        // msg.writeTo(System.out);
        // System.out.println();
        Node n = msg.getSOAPBody().getChildNodes().item(0);
        // System.out.println("num of attributes is: "+
        // n.getAttributes().getLength());
        assertTrue(n.getAttributes().getLength() == 1);
    }
}
Also used : DatabindingFactory(com.oracle.webservices.api.databinding.DatabindingFactory) QName(javax.xml.namespace.QName) Node(org.w3c.dom.Node) DatabindingModeFeature(com.oracle.webservices.api.databinding.DatabindingModeFeature) Method(java.lang.reflect.Method) SOAPMessage(jakarta.xml.soap.SOAPMessage) Databinding(com.oracle.webservices.api.databinding.Databinding) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) JavaCallInfo(com.oracle.webservices.api.databinding.JavaCallInfo) MessageContext(com.oracle.webservices.api.message.MessageContext)

Example 23 with SOAPMessage

use of jakarta.xml.soap.SOAPMessage in project metro-jax-ws by eclipse-ee4j.

the class WrapperNSTest method testWrapperNS_JAXBRI.

public void testWrapperNS_JAXBRI() throws Exception {
    Class<?> sei = MyHelloRPC.class;
    DatabindingFactory fac = DatabindingFactory.newInstance();
    Databinding.Builder b = fac.createBuilder(sei, null);
    DatabindingModeFeature dbf = new DatabindingModeFeature("glassfish.jaxb");
    WebServiceFeature[] f = { dbf };
    b.feature(f);
    b.serviceName(new QName("http://echo.org/", "helloService"));
    b.portName(new QName("http://echo.org/", "helloPort"));
    Databinding db = b.build();
    {
        Method method = findMethod(sei, "echoString");
        Object[] args = { "test" };
        JavaCallInfo call = db.createJavaCallInfo(method, args);
        MessageContext mc = db.serializeRequest(call);
        SOAPMessage msg = mc.getSOAPMessage();
        // System.out.println("------------------ glassfish");
        // msg.writeTo(System.out);
        // System.out.println();
        Node n = msg.getSOAPBody().getChildNodes().item(0);
        // System.out.println("num of attributes is: "+
        // n.getAttributes().getLength());
        assertTrue(n.getAttributes().getLength() == 1);
    }
}
Also used : DatabindingFactory(com.oracle.webservices.api.databinding.DatabindingFactory) QName(javax.xml.namespace.QName) Node(org.w3c.dom.Node) DatabindingModeFeature(com.oracle.webservices.api.databinding.DatabindingModeFeature) Method(java.lang.reflect.Method) SOAPMessage(jakarta.xml.soap.SOAPMessage) Databinding(com.oracle.webservices.api.databinding.Databinding) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) JavaCallInfo(com.oracle.webservices.api.databinding.JavaCallInfo) MessageContext(com.oracle.webservices.api.message.MessageContext)

Example 24 with SOAPMessage

use of jakarta.xml.soap.SOAPMessage in project metro-jax-ws by eclipse-ee4j.

the class DispatchHelloLiteralTest method getSOAPMessage.

SOAPMessage getSOAPMessage(Source msg) throws Exception {
    MessageFactory factory = MessageFactory.newInstance();
    SOAPMessage message = factory.createMessage();
    message.getSOAPPart().setContent((Source) msg);
    message.saveChanges();
    return message;
}
Also used : MessageFactory(jakarta.xml.soap.MessageFactory) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Example 25 with SOAPMessage

use of jakarta.xml.soap.SOAPMessage in project metro-jax-ws by eclipse-ee4j.

the class DispatchHello method testHelloRequestResponseSOAPMessage.

public void testHelloRequestResponseSOAPMessage() throws Exception {
    Dispatch dispatch = getDispatchSOAPMessage();
    assertTrue(dispatch != null);
    assertTrue(dispatch instanceof com.sun.xml.ws.client.dispatch.SOAPMessageDispatch);
    byte[] bytes = helloSM.getBytes();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
    Source source = makeStreamSource(helloSM);
    SOAPMessage message = getSOAPMessage(source);
    Object result = dispatch.invoke(message);
    // todo:need to check contents
    assertTrue(result instanceof SOAPMessage);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Dispatch(jakarta.xml.ws.Dispatch) SOAPMessage(jakarta.xml.soap.SOAPMessage) Source(javax.xml.transform.Source)

Aggregations

SOAPMessage (jakarta.xml.soap.SOAPMessage)181 MessageFactory (jakarta.xml.soap.MessageFactory)66 ByteArrayInputStream (java.io.ByteArrayInputStream)51 SOAPBody (jakarta.xml.soap.SOAPBody)37 SOAPException (jakarta.xml.soap.SOAPException)36 QName (javax.xml.namespace.QName)31 MimeHeaders (jakarta.xml.soap.MimeHeaders)27 Source (javax.xml.transform.Source)25 StreamSource (javax.xml.transform.stream.StreamSource)25 WebServiceException (jakarta.xml.ws.WebServiceException)24 ByteArrayOutputStream (java.io.ByteArrayOutputStream)21 SAAJMessage (com.sun.xml.ws.message.saaj.SAAJMessage)19 Element (org.w3c.dom.Element)18 Node (org.w3c.dom.Node)18 Packet (com.sun.xml.ws.api.message.Packet)17 Message (com.sun.xml.ws.api.message.Message)16 Iterator (java.util.Iterator)14 SOAPElement (jakarta.xml.soap.SOAPElement)12 AttachmentPart (jakarta.xml.soap.AttachmentPart)11 Dispatch (jakarta.xml.ws.Dispatch)10