Search in sources :

Example 31 with SOAPBodyElement

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

the class LogHandler method handleOutbound.

@Override
protected boolean handleOutbound(SOAPMessageContext msgContext) {
    log.info("handleOutbound");
    try {
        SOAPMessage soapMessage = msgContext.getMessage();
        getFailsafeSOAPHeader(soapMessage);
        SOAPBody soapBody = soapMessage.getSOAPBody();
        // SOAPFactory soapFactory = SOAPFactory.newInstance();
        // Name headerName = soapFactory.createName("LogHandlerOutbound", "ns1", "http://somens");
        // SOAPHeaderElement she = soapHeader.addHeaderElement(headerName);
        // she.setValue("true");
        SOAPBodyElement soapBodyElement = (SOAPBodyElement) soapBody.getChildElements().next();
        SOAPElement soapElement = (SOAPElement) soapBodyElement.getChildElements().next();
        String value = soapElement.getValue();
        soapElement.setValue(value + "|LogOut");
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
    return true;
}
Also used : SOAPBody(javax.xml.soap.SOAPBody) WebServiceException(javax.xml.ws.WebServiceException) SOAPException(javax.xml.soap.SOAPException) SOAPElement(javax.xml.soap.SOAPElement) SOAPMessage(javax.xml.soap.SOAPMessage) SOAPBodyElement(javax.xml.soap.SOAPBodyElement)

Example 32 with SOAPBodyElement

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

the class LogHandler method handleInbound.

@Override
protected boolean handleInbound(SOAPMessageContext msgContext) {
    log.info("handleInbound");
    try {
        SOAPMessage soapMessage = msgContext.getMessage();
        getFailsafeSOAPHeader(soapMessage);
        SOAPBody soapBody = soapMessage.getSOAPBody();
        // SOAPFactory soapFactory = SOAPFactory.newInstance();
        // Name headerName = soapFactory.createName("LogHandlerInbound", "ns1", "http://somens");
        // SOAPHeaderElement she = soapHeader.addHeaderElement(headerName);
        // she.setValue("true");
        SOAPBodyElement soapBodyElement = (SOAPBodyElement) soapBody.getChildElements().next();
        SOAPElement soapElement = (SOAPElement) soapBodyElement.getChildElements().next();
        String value = soapElement.getValue();
        soapElement.setValue(value + "|LogIn");
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
    return true;
}
Also used : SOAPBody(javax.xml.soap.SOAPBody) WebServiceException(javax.xml.ws.WebServiceException) SOAPException(javax.xml.soap.SOAPException) SOAPElement(javax.xml.soap.SOAPElement) SOAPMessage(javax.xml.soap.SOAPMessage) SOAPBodyElement(javax.xml.soap.SOAPBodyElement)

Example 33 with SOAPBodyElement

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

the class RoutingHandler method handleOutbound.

@Override
protected boolean handleOutbound(SOAPMessageContext msgContext) {
    log.info("handleOutbound");
    try {
        SOAPMessage soapMessage = msgContext.getMessage();
        soapMessage.getSOAPHeader();
        SOAPBody soapBody = soapMessage.getSOAPBody();
        // SOAPFactory soapFactory = SOAPFactory.newInstance();
        // Name headerName = soapFactory.createName("RoutingHandlerOutbound", "ns1", "http://somens");
        // SOAPHeaderElement she = soapHeader.addHeaderElement(headerName);
        // she.setValue("true");
        SOAPBodyElement soapBodyElement = (SOAPBodyElement) soapBody.getChildElements().next();
        SOAPElement soapElement = (SOAPElement) soapBodyElement.getChildElements().next();
        String value = soapElement.getValue();
        soapElement.setValue(value + "|RoutOut");
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
    return true;
}
Also used : SOAPBody(javax.xml.soap.SOAPBody) WebServiceException(javax.xml.ws.WebServiceException) SOAPException(javax.xml.soap.SOAPException) SOAPElement(javax.xml.soap.SOAPElement) SOAPMessage(javax.xml.soap.SOAPMessage) SOAPBodyElement(javax.xml.soap.SOAPBodyElement)

Example 34 with SOAPBodyElement

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

the class MultipartContentTypeTestCase method testSendMultipartSoapMessage.

@Test
@RunAsClient
public void testSendMultipartSoapMessage() throws Exception {
    final MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    final SOAPMessage msg = msgFactory.createMessage();
    final SOAPBodyElement bodyElement = msg.getSOAPBody().addBodyElement(new QName("urn:ledegen:soap-attachment:1.0", "echoImage"));
    bodyElement.addTextNode("cid:" + IN_IMG_NAME);
    final AttachmentPart ap = msg.createAttachmentPart();
    ap.setDataHandler(getResource("saaj/jbws3857/" + IN_IMG_NAME));
    ap.setContentId(IN_IMG_NAME);
    msg.addAttachmentPart(ap);
    final SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance();
    final SOAPConnection connection = conFactory.createConnection();
    final SOAPMessage response = connection.call(msg, new URL("http://" + baseURL.getHost() + ":" + baseURL.getPort() + "/" + PROJECT_NAME + "/testServlet"));
    final String contentTypeWeHaveSent = getBodyElementTextValue(response);
    assertContentTypeStarts("multipart/related", contentTypeWeHaveSent);
}
Also used : SOAPConnectionFactory(javax.xml.soap.SOAPConnectionFactory) MessageFactory(javax.xml.soap.MessageFactory) QName(javax.xml.namespace.QName) SOAPConnection(javax.xml.soap.SOAPConnection) AttachmentPart(javax.xml.soap.AttachmentPart) SOAPMessage(javax.xml.soap.SOAPMessage) URL(java.net.URL) SOAPBodyElement(javax.xml.soap.SOAPBodyElement) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 35 with SOAPBodyElement

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

the class SoapMultipartCheckerServlet method replyRequestedContentTypeInResponse.

private void replyRequestedContentTypeInResponse(final String requestedContentType, final HttpServletResponse resp) throws Exception {
    final MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    final SOAPMessage msg = msgFactory.createMessage();
    final SOAPBodyElement bodyElement = msg.getSOAPBody().addBodyElement(new QName("urn:not-important:1.0", "requestedContentType"));
    bodyElement.addTextNode(requestedContentType);
    resp.setStatus(HttpServletResponse.SC_OK);
    resp.setHeader("Content-Type", "application/soap+xml; charset=utf-8");
    final OutputStream os = resp.getOutputStream();
    msg.writeTo(os);
    os.close();
}
Also used : MessageFactory(javax.xml.soap.MessageFactory) QName(javax.xml.namespace.QName) OutputStream(java.io.OutputStream) SOAPMessage(javax.xml.soap.SOAPMessage) SOAPBodyElement(javax.xml.soap.SOAPBodyElement)

Aggregations

SOAPBodyElement (javax.xml.soap.SOAPBodyElement)44 SOAPMessage (javax.xml.soap.SOAPMessage)42 SOAPBody (javax.xml.soap.SOAPBody)39 SOAPElement (javax.xml.soap.SOAPElement)38 SOAPException (javax.xml.soap.SOAPException)34 WebServiceException (javax.xml.ws.WebServiceException)32 QName (javax.xml.namespace.QName)10 SOAPMessageContext (javax.xml.ws.handler.soap.SOAPMessageContext)8 SOAPHeaderElement (javax.xml.soap.SOAPHeaderElement)7 MessageFactory (javax.xml.soap.MessageFactory)6 Name (javax.xml.soap.Name)6 SOAPFactory (javax.xml.soap.SOAPFactory)6 SOAPHeader (javax.xml.soap.SOAPHeader)6 IOException (java.io.IOException)4 AttachmentPart (javax.xml.soap.AttachmentPart)3 Test (org.junit.Test)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 URISyntaxException (java.net.URISyntaxException)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2