OperationDescription operationDesc =
getOperationDescription(mc); //mc.getOperationDescription();
//Set SOAP Operation Related properties in SOAPMessageContext.
ContextUtils.addWSDLProperties(mc);
Protocol requestProtocol = mc.getMessage().getProtocol();
MethodMarshaller methodMarshaller =
getMethodMarshaller(mc.getMessage().getProtocol(), mc.getOperationDescription());
Object[] methodInputParams =
methodMarshaller.demarshalRequest(mc.getMessage(), mc.getOperationDescription());
Method target = getJavaMethod(mc, serviceImplClass);
if (log.isDebugEnabled()) {
// At this point, the OpDesc includes everything we know, including the actual method
// on the service impl we will delegate to; it was set by getJavaMethod(...) above.
log.debug("JavaBeanDispatcher about to invoke using OperationDesc: " +
operationDesc.toString());
}
//At this point, we have the method that is going to be invoked and
//the parameter data to invoke it with, so we use the instance and
//do the invoke.
//Passing method input params to grab holder values, if any.
boolean faultThrown = false;
Throwable fault = null;
Object response = null;
try {
response = target.invoke(serviceInstance, methodInputParams);
} catch (Exception e) {
faultThrown = true;
fault = e;
if (log.isDebugEnabled()) {
log.debug("Exception invoking a method of " +
serviceImplClass.toString() + " of instance " +
serviceInstance.toString());
log.debug("Exception type thrown: " + e.getClass().getName());
log.debug("Method = " + target.toGenericString());
for (int i = 0; i < methodInputParams.length; i++) {
String value = (methodInputParams[i] == null) ? "null" :
methodInputParams[i].getClass().toString();
log.debug(" Argument[" + i + "] is " + value);
}
}
}
Message message = null;
if (operationDesc.isOneWay()) {
// If the operation is one-way, then we can just return null because
// we cannot create a MessageContext for one-way responses.
return null;
} else if (faultThrown) {
message = methodMarshaller.marshalFaultResponse(fault, mc.getOperationDescription(),
requestProtocol); // Send the response using the same protocol as the request
} else if (target.getReturnType().getName().equals("void")) {
message = methodMarshaller
.marshalResponse(null, methodInputParams, mc.getOperationDescription(),
requestProtocol); // Send the response using the same protocol as the request
} else {
message = methodMarshaller
.marshalResponse(response, methodInputParams, mc.getOperationDescription(),
requestProtocol); // Send the response using the same protocol as the request
}
MessageContext responseMsgCtx = null;