Search in sources :

Example 1 with SOAPFaultException

use of javax.xml.rpc.soap.SOAPFaultException in project tomee by apache.

the class HandlerChainImpl method handleRequest.

public boolean handleRequest(MessageContext context) {
    MessageSnapshot snapshot = new MessageSnapshot(context);
    try {
        for (int i = 0; i < size(); i++) {
            Handler currentHandler = (Handler) get(i);
            invokedHandlers.addFirst(currentHandler);
            try {
                if (!currentHandler.handleRequest(context)) {
                    return false;
                }
            } catch (SOAPFaultException e) {
                throw e;
            }
        }
    } finally {
        saveChanges(context);
    }
    if (!snapshot.equals(context)) {
        throw new IllegalStateException("The soap message operation or arguments were illegally modified by the HandlerChain");
    }
    return true;
}
Also used : Handler(javax.xml.rpc.handler.Handler) SOAPFaultException(javax.xml.rpc.soap.SOAPFaultException)

Example 2 with SOAPFaultException

use of javax.xml.rpc.soap.SOAPFaultException in project Payara by payara.

the class WsUtil method throwSOAPFaultException.

public void throwSOAPFaultException(String faultString, SOAPMessage soapMessage) throws SOAPFaultException {
    SOAPFaultException sfe = null;
    try {
        SOAPPart sp = soapMessage.getSOAPPart();
        SOAPEnvelope se = sp.getEnvelope();
        // Consume the request
        SOAPBody sb = se.getBody();
        // Access the child elements of body
        Iterator iter = sb.getChildElements();
        // any request body nodes.
        if (iter.hasNext()) {
            SOAPBodyElement requestBody = (SOAPBodyElement) iter.next();
            // detach this node from the tree
            requestBody.detachNode();
        }
        SOAPFault soapFault = sb.addFault();
        se.setEncodingStyle(SOAPConstants.URI_ENCODING);
        String faultActor = "http://schemas.xmlsoap.org/soap/actor/next";
        QName faultCode = SOAPConstants.FAULT_CODE_SERVER;
        soapFault.setFaultCode("env:" + faultCode.getLocalPart());
        soapFault.setFaultString(faultString);
        soapFault.setFaultActor(faultActor);
        sfe = new SOAPFaultException(faultCode, faultActor, faultString, null);
    } catch (SOAPException se) {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, LogUtils.EXCEPTION_THROWN, se);
        }
    }
    if (sfe != null) {
        throw sfe;
    }
}
Also used : QName(javax.xml.namespace.QName) SOAPFaultException(javax.xml.rpc.soap.SOAPFaultException)

Aggregations

SOAPFaultException (javax.xml.rpc.soap.SOAPFaultException)2 QName (javax.xml.namespace.QName)1 Handler (javax.xml.rpc.handler.Handler)1