Capability capability = getCapabilityForAction(action);
if (capability == null)
{
Object[] filler = { getContextPath(), action };
SoapFault fault = new SoapFault(_MESSAGES.get("ActionNotSupported", filler));
return fault.toXML();
}
MessageHandler handler = capability.getMessageHandler(action);
Method method = handler.getMethod();
Object[] parameters = null;
try
{
//
// translate from XML -> POJO. the reflection call will take
// care of casting the generic Object references to the actual
// method parameter types
//
parameters = handler.fromXML(soapBody);
//
// invoke operation and translate result to XML
//
Object result = method.invoke(capability, parameters);
return handler.toXML(result);
}
catch (Throwable error)
{
//
// the exception is the generic reflection error, and useless
// to the programmer - we want to report on the REAL cause
//
Throwable cause = error.getCause();
if (cause != null) // sanity check
error = cause;
Logger log = getLog();
//
// log the details of de-serialization and reflection
//
if (parameters != null)
LoggingUtils.logCall(log, method, parameters);
LoggingUtils.logError(log, error);
SoapFault response = SoapUtils.convertToFault(error);
return response.toXML();
}
}