dims 02/03/06 06:43:59
Modified: java/src/org/apache/axis/providers/java RPCProvider.java
Log:
Throw "Method not found" when we finish iterating through the method array and did
not find anything suitable. Right now there is a ArrayIndexOutOfBoundsException if the
method is not found in the array for some reason.
Revision Changes Path
1.45 +21 -13
xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java
Index: RPCProvider.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- RPCProvider.java 5 Mar 2002 14:02:13 -0000 1.44
+++ RPCProvider.java 6 Mar 2002 14:43:58 -0000 1.45
@@ -77,6 +77,7 @@
import java.lang.reflect.InvocationTargetException;
import java.util.StringTokenizer;
import java.util.Vector;
+import java.util.Iterator;
/**
* Implement message processing by walking over RPCElements of the
@@ -198,16 +199,16 @@
// wsdl. Thus the following code only works if there is no
// overloading.
int numberOfBodyArgs = args.size();
- Method[] method = getMethod(jc, mName);
+ Method[] methods = getMethod(jc, mName);
// If the method wasn't found, maybe it needs some Java mangling (ie.,
it's a Java
// keyword or it's capitalized and the java mapping requires lowercase).
- if (method == null) {
+ if (methods == null) {
mName = JavaUtils.xmlNameToJava(mName);
- method = getMethod(jc, mName);
+ methods = getMethod(jc, mName);
}
- if ( method == null )
+ if ( methods == null )
throw new AxisFault( "AxisServer.error",
JavaUtils.getMessage("noMethod00", mName,
msgContext.getTargetService()),
null, null );
@@ -217,10 +218,11 @@
Exception ex = null;
// There might be more than one method with this name, try them all.
- int m = 0;
- for (m = 0; m < method.length; ++m) {
+ int index = 0;
+ for (index = 0; index < methods.length; index++) {
+ Method method = methods[index];
ex = null;
- params = method[m].getParameterTypes();
+ params = method.getParameterTypes();
// Don't bother with this one if it has FEWER params
if (argValues != null) {
@@ -257,7 +259,7 @@
// Note that if the method returns a primitive, invoke(...)
automatically
// wraps it in a java.lang class representing the primitive.
try {
- objRes = method[m].invoke(obj, argValues);
+ objRes = method.invoke(obj, argValues);
break;
} catch (IllegalArgumentException e) {
// Hm - maybe we can help this with a conversion or two...
@@ -274,7 +276,7 @@
// OK, now try again...
try {
- objRes = method[m].invoke( obj, argValues );
+ objRes = method.invoke( obj, argValues );
break;
} catch (IllegalArgumentException exp) {
StringBuffer argbuf = new StringBuffer();
@@ -291,7 +293,7 @@
new String[] {
exp.getMessage(),
objName,
- method[m].getName(),
+ method.getName(),
argbuf.toString()});
ex = new IllegalArgumentException(msg);
continue;
@@ -304,6 +306,12 @@
throw ex;
}
+ // If we've finished iterating through all the methods, throw an
exception.
+ if ( index == methods.length )
+ throw new AxisFault( "AxisServer.error",
+ JavaUtils.getMessage("noMethod00", mName,
msgContext.getTargetService()),
+ null, null );
+
if (log.isDebugEnabled())
log.debug(JavaUtils.getMessage("result00", "" + objRes));
@@ -324,7 +332,7 @@
resBody.addParam ((RPCParam) list.get (i));
}
else {
- resBody.addParam (new RPCParam (getParameterName(obj,
method[m],i, mName),
+ resBody.addParam (new RPCParam (getParameterName(obj,
methods[index],i, mName),
list.get (i)));
}
}
@@ -334,7 +342,7 @@
RPCParam param = new RPCParam(returnQName, objRes);
resBody.addParam(param);
}
- } else if (method[m].getReturnType() != Void.TYPE) {
+ } else if (methods[index].getReturnType() != Void.TYPE) {
QName returnQName = getReturnQName(serviceDesc, mName);
RPCParam param = new RPCParam(returnQName, objRes);
resBody.addParam(param);
@@ -348,7 +356,7 @@
// Create an RPCParam by converting the Holder back into
// the held type.
resBody.addParam (new RPCParam (getParameterName(obj,
- method[m],
+ methods[index],
i,
mName,
args),