Search in sources :

Example 6 with AxisBindingOperation

use of org.apache.axis2.description.AxisBindingOperation in project pentaho-platform by pentaho.

the class AbstractAxisServiceContentGenerator method processAxisFault.

/**
 * Handles processing of Axis exceptions.
 *
 * @param msgContext
 *          The message context that experienced an error
 * @param out
 *          The output stream to write to
 * @param e
 *          The error that occurred
 */
protected void processAxisFault(MessageContext msgContext, OutputStream out, Throwable e) {
    // $NON-NLS-1$
    IParameterProvider pathParams = parameterProviders.get("path");
    // is this HTTP?
    boolean http = msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE) != null;
    if (http) {
        // $NON-NLS-1$
        HttpServletResponse res = (HttpServletResponse) pathParams.getParameter("httpresponse");
        // If the fault is not going along the back channel we should be 202ing
        if (AddressingHelper.isFaultRedirected(msgContext)) {
            res.setStatus(HttpServletResponse.SC_ACCEPTED);
        } else {
            // set the status of the HTTP response
            String status = (String) msgContext.getProperty(Constants.HTTP_RESPONSE_STATE);
            try {
                if (status == null) {
                    res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
                } else {
                    int sc = Integer.parseInt(status);
                    if (sc >= 400) {
                        res.sendError(sc);
                    } else {
                        res.setStatus(sc);
                    }
                }
            } catch (IOException e1) {
                if (status == null) {
                    res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
                } else {
                    int sc = Integer.parseInt(status);
                    res.setStatus(sc);
                }
            }
            AxisBindingOperation axisBindingOperation = (AxisBindingOperation) msgContext.getProperty(Constants.AXIS_BINDING_OPERATION);
            if (axisBindingOperation != null) {
                AxisBindingMessage fault = axisBindingOperation.getFault((String) msgContext.getProperty(Constants.FAULT_NAME));
                if (fault != null) {
                    Integer code = (Integer) fault.getProperty(WSDL2Constants.ATTR_WHTTP_CODE);
                    if (code != null) {
                        res.setStatus(code.intValue());
                    }
                }
            }
        }
    }
    try {
        // now process the fault
        handleFault(msgContext, out, http, e);
    } catch (IOException axisFault) {
        // $NON-NLS-1$
        String message = Messages.getInstance().getErrorString("WebServiceContentGenerator.ERROR_0003_PROCESSING_FAULT");
        getLogger().error(message, axisFault);
    }
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) HttpServletResponse(javax.servlet.http.HttpServletResponse) AxisBindingOperation(org.apache.axis2.description.AxisBindingOperation) AxisBindingMessage(org.apache.axis2.description.AxisBindingMessage) IOException(java.io.IOException)

Aggregations

AxisBindingOperation (org.apache.axis2.description.AxisBindingOperation)6 EndpointReference (org.apache.axis2.addressing.EndpointReference)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 AxisFault (org.apache.axis2.AxisFault)2 MessageContext (org.apache.axis2.context.MessageContext)2 AxisEndpoint (org.apache.axis2.description.AxisEndpoint)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Map (java.util.Map)1 Stack (java.util.Stack)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 SOAPFactory (org.apache.axiom.soap.SOAPFactory)1 AxisBinding (org.apache.axis2.description.AxisBinding)1 AxisBindingMessage (org.apache.axis2.description.AxisBindingMessage)1 AxisOperation (org.apache.axis2.description.AxisOperation)1 AxisService (org.apache.axis2.description.AxisService)1 MultipleEntryHashMap (org.apache.axis2.util.MultipleEntryHashMap)1 MessageContext (org.apache.synapse.MessageContext)1 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)1 TemplateContext (org.apache.synapse.mediators.template.TemplateContext)1