// suitable for passing to java.lang.reflect.Method.invoke()
// Make sure we respect parameter ordering if we know about it
// from metadata, and handle whatever conversions are necessary
// (values -> Holders, etc)
for ( int i = 0 ; i < numArgs ; i++ ) {
RPCParam rpcParam = (RPCParam)args.get(i);
Object value = rpcParam.getValue();
// first check the type on the paramter
ParameterDesc paramDesc = rpcParam.getParamDesc();
// if we found some type info try to make sure the value type is
// correct. For instance, if we deserialized a xsd:dateTime in
// to a Calendar and the service takes a Date, we need to convert
if (paramDesc != null && paramDesc.getJavaType() != null) {
// Get the type in the signature (java type or its holder)
Class sigType = paramDesc.getJavaType();
// Convert the value into the expected type in the signature
value = JavaUtils.convert(value,
sigType);
rpcParam.setValue(value);
if (paramDesc.getMode() == ParameterDesc.INOUT) {
outs.add(rpcParam);
}
}
// Put the value (possibly converted) in the argument array
// make sure to use the parameter order if we have it
if (paramDesc == null || paramDesc.getOrder() == -1) {
argValues[i] = value;
} else {
argValues[paramDesc.getOrder()] = value;
}
if (log.isDebugEnabled()) {
log.debug(" " + JavaUtils.getMessage("value00",
"" + argValues[i]) );
}
}
// See if any subclasses want a crack at faulting on a bad operation
// FIXME : Does this make sense here???
String allowedMethods = (String)service.getOption("allowedMethods");
checkMethodName(msgContext, allowedMethods, operation.getName());
// Now create any out holders we need to pass in
if (numArgs < argValues.length) {
ArrayList outParams = operation.getOutParams();
for (int i = 0; i < outParams.size(); i++) {
ParameterDesc param = (ParameterDesc)outParams.get(i);
Class holderClass = param.getJavaType();
if (holderClass != null &&
Holder.class.isAssignableFrom(holderClass)) {
argValues[numArgs + i] = holderClass.newInstance();
// Store an RPCParam in the outs collection so we
// have an easy and consistent way to write these
// back to the client below
outs.add(new RPCParam(param.getQName(),
argValues[numArgs + i]));
} else {
throw new AxisFault(JavaUtils.getMessage("badOutParameter00",
"" + param.getQName(),
operation.getName()));
}
}
}
// OK! Now we can invoke the method
Object objRes = null;
try {
objRes = invokeMethod(msgContext,
operation.getMethod(),
obj, argValues);
} catch (IllegalArgumentException e) {
String methodSig = operation.getMethod().toString();
String argClasses = "";
for (int i=0; i < argValues.length; i++) {
if (argValues[i] == null) {
argClasses += "null";
} else {
argClasses += argValues[i].getClass().getName();
}
if (i+1 < argValues.length) {
argClasses += ",";
}
}
log.info(JavaUtils.getMessage("dispatchIAE00",
new String[] {methodSig, argClasses}),
e);
throw new AxisFault(JavaUtils.getMessage("dispatchIAE00",
new String[] {methodSig, argClasses}),
e);
}
/* Now put the result in the result SOAPEnvelope */
/*************************************************/
RPCElement resBody = new RPCElement(methodName + "Response");
resBody.setPrefix( body.getPrefix() );
resBody.setNamespaceURI( body.getNamespaceURI() );
resBody.setEncodingStyle(msgContext.getEncodingStyle());
// Return first
if ( operation.getMethod().getReturnType() != Void.TYPE ) {
QName returnQName = operation.getReturnQName();
if (returnQName == null) {
returnQName = new QName("", methodName + "Return");
}
// For SOAP 1.2, add a result
if (msgContext.getSOAPConstants() == SOAPConstants.SOAP12_CONSTANTS)
{
RPCParam result = new RPCParam
(Constants.QNAME_RPC_RESULT, returnQName.getLocalPart());
resBody.addParam(result);
}
RPCParam param = new RPCParam(returnQName, objRes);
param.setParamDesc(operation.getReturnParamDesc());
resBody.addParam(param);
}
// Then any other out params
if (!outs.isEmpty()) {
for (Iterator i = outs.iterator(); i.hasNext();) {
// We know this has a holder, so just unwrap the value
RPCParam param = (RPCParam) i.next();
Holder holder = (Holder)param.getValue();
Object value = JavaUtils.getHolderValue(holder);
ParameterDesc paramDesc = param.getParamDesc();
param.setValue(value);
resBody.addParam(param);
}
}
resEnv.addBodyElement(resBody);