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;
}
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;
}
Aggregations