Search in sources :

Example 26 with SOAPEnvelope

use of javax.xml.soap.SOAPEnvelope in project jbossws-cxf by jbossws.

the class ProviderMessageTestCase method testProviderMessage.

@Test
@RunAsClient
public void testProviderMessage() throws Exception {
    SOAPMessage reqMsg = getRequestMessage();
    SOAPEnvelope reqEnv = reqMsg.getSOAPPart().getEnvelope();
    URL epURL = baseURL;
    SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
    SOAPMessage resMsg = con.call(reqMsg, epURL);
    SOAPEnvelope resEnv = resMsg.getSOAPPart().getEnvelope();
    SOAPHeader soapHeader = resEnv.getHeader();
    if (soapHeader != null)
        soapHeader.detachNode();
    assertEquals(reqEnv, resEnv);
}
Also used : SOAPConnection(javax.xml.soap.SOAPConnection) SOAPEnvelope(javax.xml.soap.SOAPEnvelope) SOAPMessage(javax.xml.soap.SOAPMessage) URL(java.net.URL) SOAPHeader(javax.xml.soap.SOAPHeader) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 27 with SOAPEnvelope

use of javax.xml.soap.SOAPEnvelope in project jbossws-cxf by jbossws.

the class ClientHandler method handleInbound.

@Override
public boolean handleInbound(SOAPMessageContext msgContext) {
    try {
        SOAPMessage soapMessage = msgContext.getMessage();
        SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
        String nsURI = soapEnvelope.getNamespaceURI();
        SOAPElement soapElement = (SOAPElement) soapMessage.getSOAPBody().getChildElements().next();
        soapElement = (SOAPElement) soapElement.getChildElements().next();
        String value = soapElement.getValue();
        soapElement.setValue(value + ":" + nsURI);
        return true;
    } catch (SOAPException ex) {
        throw new WebServiceException(ex);
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) SOAPException(javax.xml.soap.SOAPException) SOAPElement(javax.xml.soap.SOAPElement) SOAPEnvelope(javax.xml.soap.SOAPEnvelope) SOAPMessage(javax.xml.soap.SOAPMessage)

Example 28 with SOAPEnvelope

use of javax.xml.soap.SOAPEnvelope in project jbossws-cxf by jbossws.

the class ServerHandler method handleInbound.

@Override
public boolean handleInbound(SOAPMessageContext msgContext) {
    try {
        SOAPMessage soapMessage = msgContext.getMessage();
        SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
        nsURI = soapEnvelope.getNamespaceURI();
        return true;
    } catch (SOAPException ex) {
        throw new WebServiceException(ex);
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) SOAPException(javax.xml.soap.SOAPException) SOAPEnvelope(javax.xml.soap.SOAPEnvelope) SOAPMessage(javax.xml.soap.SOAPMessage)

Example 29 with SOAPEnvelope

use of javax.xml.soap.SOAPEnvelope in project Payara by payara.

the class WebServicesDelegateImpl method getName.

private Name getName(SOAPMessage message) {
    Name rvalue = null;
    SOAPPart soap = message.getSOAPPart();
    if (soap != null) {
        try {
            SOAPEnvelope envelope = soap.getEnvelope();
            if (envelope != null) {
                SOAPBody body = envelope.getBody();
                if (body != null) {
                    Iterator it = body.getChildElements();
                    while (it.hasNext()) {
                        Object o = it.next();
                        if (o instanceof SOAPElement) {
                            rvalue = ((SOAPElement) o).getElementName();
                            break;
                        }
                    }
                }
            }
        } catch (SOAPException se) {
            if (_logger.isLoggable(Level.FINE)) {
                _logger.log(Level.FINE, "WSS: Unable to get SOAP envelope", se);
            }
        }
    }
    return rvalue;
}
Also used : SOAPBody(javax.xml.soap.SOAPBody) SOAPException(javax.xml.soap.SOAPException) SOAPPart(javax.xml.soap.SOAPPart) Iterator(java.util.Iterator) SOAPElement(javax.xml.soap.SOAPElement) SOAPEnvelope(javax.xml.soap.SOAPEnvelope) Name(javax.xml.soap.Name) QName(javax.xml.namespace.QName)

Example 30 with SOAPEnvelope

use of javax.xml.soap.SOAPEnvelope in project openhab1-addons by openhab.

the class Tr064Comm method constructTr064Msg.

/***
     * sets all required namespaces and prepares the SOAP message to send
     * creates skeleton + body data
     *
     * @param bodyData is attached to skeleton to form entire SOAP message
     * @return ready to send SOAP message
     */
private SOAPMessage constructTr064Msg(SOAPBodyElement bodyData) {
    SOAPMessage soapMsg = null;
    try {
        MessageFactory msgFac;
        msgFac = MessageFactory.newInstance();
        soapMsg = msgFac.createMessage();
        soapMsg.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");
        soapMsg.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, "UTF-8");
        SOAPPart part = soapMsg.getSOAPPart();
        // valid for entire SOAP msg
        String namespace = "s";
        // create suitable fbox envelope
        SOAPEnvelope envelope = part.getEnvelope();
        envelope.setPrefix(namespace);
        // delete standard namespace which was already set
        envelope.removeNamespaceDeclaration("SOAP-ENV");
        envelope.addNamespaceDeclaration(namespace, "http://schemas.xmlsoap.org/soap/envelope/");
        Name nEncoding = envelope.createName("encodingStyle", namespace, "http://schemas.xmlsoap.org/soap/encoding/");
        envelope.addAttribute(nEncoding, "http://schemas.xmlsoap.org/soap/encoding/");
        // create empty header
        SOAPHeader header = envelope.getHeader();
        header.setPrefix(namespace);
        // create body with command based on parameter
        SOAPBody body = envelope.getBody();
        body.setPrefix(namespace);
        // bodyData already prepared. Needs only be added
        body.addChildElement(bodyData);
    } catch (Exception e) {
        logger.error("Error creating SOAP message for fbox request with data {}", bodyData);
        e.printStackTrace();
    }
    return soapMsg;
}
Also used : SOAPBody(javax.xml.soap.SOAPBody) MessageFactory(javax.xml.soap.MessageFactory) SOAPPart(javax.xml.soap.SOAPPart) SOAPEnvelope(javax.xml.soap.SOAPEnvelope) SOAPMessage(javax.xml.soap.SOAPMessage) SOAPHeader(javax.xml.soap.SOAPHeader) XPathExpressionException(javax.xml.xpath.XPathExpressionException) URISyntaxException(java.net.URISyntaxException) SOAPException(javax.xml.soap.SOAPException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ClientProtocolException(org.apache.http.client.ClientProtocolException) IOException(java.io.IOException) Name(javax.xml.soap.Name) QName(javax.xml.namespace.QName)

Aggregations

SOAPEnvelope (javax.xml.soap.SOAPEnvelope)59 SOAPMessage (javax.xml.soap.SOAPMessage)34 SOAPException (javax.xml.soap.SOAPException)31 SOAPBody (javax.xml.soap.SOAPBody)24 SOAPPart (javax.xml.soap.SOAPPart)24 SOAPElement (javax.xml.soap.SOAPElement)22 SOAPHeader (javax.xml.soap.SOAPHeader)16 Name (javax.xml.soap.Name)13 SOAPHeaderElement (javax.xml.soap.SOAPHeaderElement)13 Iterator (java.util.Iterator)12 QName (javax.xml.namespace.QName)12 WebServiceException (javax.xml.ws.WebServiceException)10 ProtocolException (javax.xml.ws.ProtocolException)7 SOAPMessageContext (javax.xml.ws.handler.soap.SOAPMessageContext)6 CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)6 Detail (javax.xml.soap.Detail)5 MessageFactory (javax.xml.soap.MessageFactory)5 SOAPConnection (javax.xml.soap.SOAPConnection)5 SOAPFault (javax.xml.soap.SOAPFault)5 Test (org.junit.Test)5