Search in sources :

Example 86 with SOAPException

use of javax.xml.soap.SOAPException 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 87 with SOAPException

use of javax.xml.soap.SOAPException 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 88 with SOAPException

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

the class ServerSOAPHandler method handleOutbound.

@Override
protected boolean handleOutbound(final SOAPMessageContext msgContext) {
    try {
        SOAPMessage message = msgContext.getMessage();
        SOAPBody body = message.getSOAPBody();
        Document document = body.extractContentAsDocument();
        NodeList nodes = document.getChildNodes();
        for (int i = 0; i < nodes.getLength(); i++) {
            Node current = nodes.item(i);
            NodeList childNodes = current.getChildNodes();
            for (int j = 0; j < childNodes.getLength(); j++) {
                Node currentChildNode = childNodes.item(j);
                if ("return".equals(currentChildNode.getLocalName())) {
                    currentChildNode.setTextContent("PutByServerSOAPHandler");
                }
            }
        }
        body.addDocument(document);
        message.saveChanges();
    } catch (SOAPException e) {
        throw new RuntimeException(e);
    }
    return true;
}
Also used : SOAPBody(javax.xml.soap.SOAPBody) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) SOAPException(javax.xml.soap.SOAPException) Document(org.w3c.dom.Document) SOAPMessage(javax.xml.soap.SOAPMessage)

Example 89 with SOAPException

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

the class CustomHandler method handleMessage.

@Override
public boolean handleMessage(SOAPMessageContext context) {
    log.debug("handleMessage...");
    try {
        SOAPMessageContext msgContext = context;
        SOAPBody body = msgContext.getMessage().getSOAPBody();
        String bodyStr = DOMWriter.printNode(body, false);
        if (bodyStr.indexOf("http://example.org/sei") < 0)
            throw new WebServiceException("Invalid body: " + bodyStr);
    } catch (SOAPException ex) {
        throw new WebServiceException(ex);
    }
    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)

Example 90 with SOAPException

use of javax.xml.soap.SOAPException 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)

Aggregations

SOAPException (javax.xml.soap.SOAPException)225 SOAPMessage (javax.xml.soap.SOAPMessage)135 SOAPElement (javax.xml.soap.SOAPElement)71 SOAPBody (javax.xml.soap.SOAPBody)62 WebServiceException (javax.xml.ws.WebServiceException)57 IOException (java.io.IOException)53 Element (org.w3c.dom.Element)36 QName (javax.xml.namespace.QName)33 SOAPBodyElement (javax.xml.soap.SOAPBodyElement)33 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)28 SOAPFault (javax.xml.soap.SOAPFault)27 SOAPEnvelope (javax.xml.soap.SOAPEnvelope)25 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)24 Node (org.w3c.dom.Node)23 SOAPFactory (javax.xml.soap.SOAPFactory)22 SOAPMessageContext (javax.xml.ws.handler.soap.SOAPMessageContext)20 SOAPHeader (javax.xml.soap.SOAPHeader)19 SOAPPart (javax.xml.soap.SOAPPart)19 Iterator (java.util.Iterator)17 Fault (org.apache.cxf.interceptor.Fault)16