Package javax.xml.soap

Examples of javax.xml.soap.SOAPMessage


        QName serviceName1 = new QName("http://objectweb.org/hello_world_soap_http", "SOAPService1");
        QName portName1 = new QName("http://objectweb.org/hello_world_soap_http", "SoapPort1");
       
        SOAPService1 service1 = new SOAPService1(wsdlURL, serviceName1);       
        InputStream is1 =  Client.class.getResourceAsStream("GreetMeDocLiteralReq1.xml");
        SOAPMessage soapReq1 = factory.createMessage(null, is1);

        Dispatch<SOAPMessage> dispSOAPMsg = service1.createDispatch(portName1,
                                                                    SOAPMessage.class, Mode.MESSAGE);
       
        System.out.println("Invoking server through Dispatch interface using SOAPMessage");
        SOAPMessage soapResp = dispSOAPMsg.invoke(soapReq1);       
        System.out.println("Response from server: " + soapResp.getSOAPBody().getTextContent());       

        QName serviceName2 = new QName("http://objectweb.org/hello_world_soap_http", "SOAPService2");
        QName portName2 = new QName("http://objectweb.org/hello_world_soap_http", "SoapPort2");
       
        SOAPService2 service2 = new SOAPService2(wsdlURL, serviceName2);
        InputStream is2 =  Client.class.getResourceAsStream("GreetMeDocLiteralReq2.xml");
        SOAPMessage soapReq2 = factory.createMessage(null, is2);
        DOMSource domReqMessage = new DOMSource(soapReq2.getSOAPPart());

        Dispatch<DOMSource> dispDOMSrcMessage = service2.createDispatch(portName2,
                                                                        DOMSource.class, Mode.MESSAGE);
        System.out.println("Invoking server through Dispatch interface using DOMSource in MESSAGE Mode");
        DOMSource domRespMessage = dispDOMSrcMessage.invoke(domReqMessage);       
        System.out.println("Response from server: "
                           + domRespMessage.getNode().getFirstChild().getTextContent());
             

        QName serviceName3 = new QName("http://objectweb.org/hello_world_soap_http", "SOAPService3");
        QName portName3 = new QName("http://objectweb.org/hello_world_soap_http", "SoapPort3");
       
        SOAPService3 service3 = new SOAPService3(wsdlURL, serviceName3);       
        InputStream is3 =  Client.class.getResourceAsStream("GreetMeDocLiteralReq3.xml");      
        SOAPMessage soapReq3 = MessageFactory.newInstance().createMessage(null, is3);
        DOMSource domReqPayload = new DOMSource(soapReq3.getSOAPBody().extractContentAsDocument());
            
        Dispatch<DOMSource> dispDOMSrcPayload = service3.createDispatch(portName3,
                                                                        DOMSource.class, Mode.PAYLOAD);
        System.out.println("Invoking server through Dispatch interface using DOMSource in PAYLOAD Mode");
        DOMSource domRespPayload = dispDOMSrcPayload.invoke(domReqPayload);       
View Full Code Here


            transformer.transform(request, result);
            System.out.println("\n");
           
            InputStream is = getClass().getResourceAsStream("GreetMeDocLiteralResp3.xml");
           
            SOAPMessage greetMeResponse =  MessageFactory.newInstance().createMessage(null, is);
            is.close();           
            response.setNode(greetMeResponse.getSOAPBody().extractContentAsDocument());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return response;
    }
View Full Code Here

    private String outboundDump() {
        StringBuffer buf = new StringBuffer();
        try {
            buf.append(System.getProperty("line.separator"));
            for (int i = 0; i < outboundMessages.size(); i++) {
                SOAPMessage sm = outboundMessages.get(i);
                buf.append("[");
                buf.append(i);
                buf.append("] : ");
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                sm.writeTo(bos);
                buf.append(bos.toString());
                buf.append(System.getProperty("line.separator"));
            }
        } catch (Exception ex) {
            return "";
View Full Code Here

    }

    public void testInvoke() throws Exception {
       
        InputStream is =  getClass().getResourceAsStream("GreetMeDocLiteralReq.xml");
        SOAPMessage soapReqMsg = MessageFactory.newInstance().createMessage(null,  is);
        assertNotNull(soapReqMsg);
       
        TestDispatchImpl<SOAPMessage> dispImpl =
            new TestDispatchImpl<SOAPMessage>(bus, epr, Service.Mode.MESSAGE, SOAPMessage.class, executor);
        SOAPMessage soapRespMsg = dispImpl.invoke(soapReqMsg);
        assertNotNull(soapRespMsg);
        assertEquals("Message should contain TestSOAPInputMessage",
                     soapRespMsg.getSOAPBody().getTextContent(), "TestSOAPInputMessage");   
    }
View Full Code Here

    public void testInvokeForFaults() throws Exception {
       
        InputStream is = 
            getClass().getResourceAsStream("../bindings/soap/resources/BadRecordDocLiteral.xml");
        SOAPMessage soapReqMsg = MessageFactory.newInstance().createMessage(null,  is);
        assertNotNull(soapReqMsg);
       
        TestDispatchImpl<SOAPMessage> dispImpl =
            new TestDispatchImpl<SOAPMessage>(bus, epr, Service.Mode.MESSAGE, SOAPMessage.class, executor);
        try {
View Full Code Here

    }
   
    public void testInvokeOneWay() throws Exception {
       
        InputStream is =  getClass().getResourceAsStream("GreetMeDocLiteralReq.xml");
        SOAPMessage soapReqMsg = MessageFactory.newInstance().createMessage(null,  is);
        assertNotNull(soapReqMsg);
       
        TestDispatchImpl<SOAPMessage> dispImpl =
            new TestDispatchImpl<SOAPMessage>(bus, epr, Service.Mode.MESSAGE, SOAPMessage.class, executor);
        dispImpl.invokeOneWay(soapReqMsg);  
View Full Code Here

    }
   
    public void testInvokeAsync() throws Exception {
       
        InputStream is =  getClass().getResourceAsStream("GreetMeDocLiteralReq.xml");
        SOAPMessage soapReqMsg = MessageFactory.newInstance().createMessage(null,  is);
        assertNotNull(soapReqMsg);
       
        TestDispatchImpl<SOAPMessage> dispImpl =
            new TestDispatchImpl<SOAPMessage>(bus, epr, Service.Mode.MESSAGE, SOAPMessage.class, executor);
        Response response = dispImpl.invokeAsync(soapReqMsg);
        assertNotNull(response);       
        SOAPMessage soapRespMsg = (SOAPMessage)response.get();
        assertEquals("Message should contain TestSOAPInputMessage",
                     soapRespMsg.getSOAPBody().getTextContent(), "TestSOAPInputMessage");
    }
View Full Code Here

    }

    public DOMSource invoke(DOMSource request) {
        DOMSource response = new DOMSource();
        try {
            SOAPMessage msg = factory.createMessage();
            msg.getSOAPPart().setContent(request);
            SOAPBody body = msg.getSOAPBody();
            Node n = body.getFirstChild();

            while (n.getNodeType() != Node.ELEMENT_NODE) {
                n = n.getNextSibling();
            }
View Full Code Here

    }

    public DOMSource invoke(DOMSource request) {
        DOMSource response = new DOMSource();
        try {
            SOAPMessage msg = factory.createMessage();           
            SOAPBody body = msg.getSOAPBody();
            body.addDocument((Document)request.getNode());

            Node n = getElementChildNode(body);
            if (n.getLocalName().equals(sayHi.getLocalPart())) {
                response.setNode(sayHiResponse.getSOAPBody().extractContentAsDocument());
View Full Code Here

        public void invokeOneway(OutputStreamMessageContext context) throws IOException {
            InputStreamMessageContext ismc = context.getCorrespondingInputStreamContext();
            InputStream in = ismc.getInputStream();           
            try {
                SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(null, in);
                assertEquals("Message should contain TestSOAPInputMessage",
                             soapMessage.getSOAPBody().getTextContent(),
                             "TestSOAPInputMessage");               
            } catch (IOException e) {
                e.printStackTrace();
            } catch (SOAPException e) {
                e.printStackTrace();
View Full Code Here

TOP

Related Classes of javax.xml.soap.SOAPMessage

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.