Capability capability = getCapabilityForAction(action);
// Sanity check : is there a capability for the given action?
if (capability == null)
{
SoapFault wsaFault = new SoapFault(
String.format(
Messages.ACTION_NOT_SUPPORTED,
action,getContextPath()));
wsaFault.setCode(SoapConstants.SENDER_QNAME);
wsaFault.setSubCode(WsaConstants.ACTION_NOT_SUPPORTED_FAULT_QNAME);
Element detail = XmlUtils.createElement(WsaConstants.PROBLEM_ACTION_QNAME);
XmlUtils.setElement(detail, WsaConstants.ACTION_QNAME, action);
wsaFault.setDetail(detail);
LOGGER.error(
Messages.QMAN_100020_ACTION_NOT_SUPPORTED,
action,
getContextPath());
return wsaFault.toXML();
}
MessageHandler handler = capability.getMessageHandler(action);
Method method = handler.getMethod();
try
{
Object[]parameters = handler.fromXML(requestBody);
Object result = method.invoke(capability, parameters);
return handler.toXML(result);
}
catch (Throwable throwable)
{
LOGGER.error(
throwable,
Messages.QMAN_100037_INVOKE_OPERATION_FAILURE);
SoapFault response = SoapUtils.convertToFault(
(throwable.getCause()!= null)
? throwable.getCause()
: throwable);
return response.toXML();
}
}