Search in sources :

Example 1 with SOAPPart

use of org.apache.axis.SOAPPart in project tomee by apache.

the class AxisWsContainer method handleFault.

private Message handleFault(final AxisFault fault, final HttpResponse res, final MessageContext context) {
    Message responseMessage;
    final Element runtimeException = fault.lookupFaultDetail(Constants.QNAME_FAULTDETAIL_RUNTIMEEXCEPTION);
    logger.warning(Messages.getMessage("axisFault00"), fault);
    if (runtimeException != null) {
        // strip runtime details
        fault.removeFaultDetail(Constants.QNAME_FAULTDETAIL_RUNTIMEEXCEPTION);
    }
    final int status = fault.getFaultCode().getLocalPart().startsWith("Server.Unauth") ? HttpServletResponse.SC_UNAUTHORIZED : HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
    if (status == HttpServletResponse.SC_UNAUTHORIZED) {
        // unauth access results in authentication request
        // TODO: less generic realm choice?
        res.setHeader("WWW-Authenticate", "Basic realm=\"AXIS\"");
    }
    res.setStatus(status);
    responseMessage = context.getResponseMessage();
    if (responseMessage == null) {
        responseMessage = new Message(fault);
        final SOAPPart soapPart = (SOAPPart) responseMessage.getSOAPPart();
        soapPart.getMessage().setMessageContext(context);
    }
    return responseMessage;
}
Also used : Message(org.apache.axis.Message) SOAPMessage(javax.xml.soap.SOAPMessage) Element(org.w3c.dom.Element) SOAPPart(org.apache.axis.SOAPPart)

Example 2 with SOAPPart

use of org.apache.axis.SOAPPart in project tomee by apache.

the class AxisWsContainer method handleException.

private Message handleException(final MessageContext context, final HttpResponse res, final Exception e) {
    Message responseMessage;
    // other exceptions are internal trouble
    responseMessage = context.getResponseMessage();
    res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    Message responseMsg = responseMessage;
    logger.warning(Messages.getMessage("exception00"), e);
    if (responseMsg == null) {
        final AxisFault fault = AxisFault.makeFault(e);
        // log the fault
        final Element runtimeException = fault.lookupFaultDetail(Constants.QNAME_FAULTDETAIL_RUNTIMEEXCEPTION);
        if (runtimeException != null) {
            logger.debug(Messages.getMessage("axisFault00"), fault);
            // strip runtime details
            fault.removeFaultDetail(Constants.QNAME_FAULTDETAIL_RUNTIMEEXCEPTION);
        }
        responseMsg = new Message(fault);
    }
    responseMessage = responseMsg;
    final SOAPPart soapPart = (SOAPPart) responseMessage.getSOAPPart();
    soapPart.getMessage().setMessageContext(context);
    return responseMessage;
}
Also used : AxisFault(org.apache.axis.AxisFault) Message(org.apache.axis.Message) SOAPMessage(javax.xml.soap.SOAPMessage) Element(org.w3c.dom.Element) SOAPPart(org.apache.axis.SOAPPart)

Aggregations

SOAPMessage (javax.xml.soap.SOAPMessage)2 Message (org.apache.axis.Message)2 SOAPPart (org.apache.axis.SOAPPart)2 Element (org.w3c.dom.Element)2 AxisFault (org.apache.axis.AxisFault)1