Search in sources :

Example 11 with SOAPBodyElement

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

the class CustomHandler method handleInbound.

@Override
protected boolean handleInbound(SOAPMessageContext msgContext) {
    try {
        SOAPMessage soapMessage = msgContext.getMessage();
        SOAPBody soapBody = soapMessage.getSOAPBody();
        SOAPBodyElement soapBodyElement = (SOAPBodyElement) soapBody.getChildElements().next();
        if (soapBodyElement.getChildElements().hasNext()) {
            SOAPElement payload = (SOAPElement) soapBodyElement.getChildElements().next();
            String value = payload.getValue();
            payload.setValue(value + "World");
        }
    } 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 12 with SOAPBodyElement

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

the class AuthorizationHandler method handleInbound.

@Override
protected boolean handleInbound(SOAPMessageContext msgContext) {
    log.info("handleInbound");
    try {
        SOAPMessage soapMessage = ((SOAPMessageContext) msgContext).getMessage();
        soapMessage.getSOAPHeader();
        SOAPBody soapBody = soapMessage.getSOAPBody();
        // SOAPFactory soapFactory = SOAPFactory.newInstance();
        // Name headerName = soapFactory.createName("AuthorizationHandlerInbound", "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 + "|AuthIn");
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
    return true;
}
Also used : SOAPBody(javax.xml.soap.SOAPBody) WebServiceException(javax.xml.ws.WebServiceException) SOAPMessageContext(javax.xml.ws.handler.soap.SOAPMessageContext) SOAPException(javax.xml.soap.SOAPException) SOAPElement(javax.xml.soap.SOAPElement) SOAPMessage(javax.xml.soap.SOAPMessage) SOAPBodyElement(javax.xml.soap.SOAPBodyElement)

Example 13 with SOAPBodyElement

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

the class AuthorizationHandler method handleOutbound.

@Override
protected boolean handleOutbound(SOAPMessageContext msgContext) {
    log.info("handleOutbound");
    try {
        SOAPMessage soapMessage = ((SOAPMessageContext) msgContext).getMessage();
        soapMessage.getSOAPHeader();
        SOAPBody soapBody = soapMessage.getSOAPBody();
        // SOAPFactory soapFactory = SOAPFactory.newInstance();
        // Name headerName = soapFactory.createName("AuthorizationHandlerOutbound", "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 + "|AuthOut");
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
    return true;
}
Also used : SOAPBody(javax.xml.soap.SOAPBody) WebServiceException(javax.xml.ws.WebServiceException) SOAPMessageContext(javax.xml.ws.handler.soap.SOAPMessageContext) SOAPException(javax.xml.soap.SOAPException) SOAPElement(javax.xml.soap.SOAPElement) SOAPMessage(javax.xml.soap.SOAPMessage) SOAPBodyElement(javax.xml.soap.SOAPBodyElement)

Example 14 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();
        SOAPHeader soapHeader = 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 : SOAPHeaderElement(javax.xml.soap.SOAPHeaderElement) 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) SOAPHeader(javax.xml.soap.SOAPHeader) SOAPFactory(javax.xml.soap.SOAPFactory) Name(javax.xml.soap.Name) SOAPBodyElement(javax.xml.soap.SOAPBodyElement)

Example 15 with SOAPBodyElement

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

the class AuthorizationHandler method handleOutbound.

@Override
protected boolean handleOutbound(SOAPMessageContext msgContext) {
    log.info("handleOutbound");
    try {
        SOAPMessage soapMessage = msgContext.getMessage();
        SOAPHeader soapHeader = soapMessage.getSOAPHeader();
        SOAPBody soapBody = soapMessage.getSOAPBody();
        SOAPFactory soapFactory = SOAPFactory.newInstance();
        Name headerName = soapFactory.createName("AuthorizationHandlerOutbound", "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 + "|AuthOut");
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
    return true;
}
Also used : SOAPHeaderElement(javax.xml.soap.SOAPHeaderElement) 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) SOAPHeader(javax.xml.soap.SOAPHeader) SOAPFactory(javax.xml.soap.SOAPFactory) Name(javax.xml.soap.Name) 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