Hi,
We are looking at Axis as a possibility on a project we are working on. My basic question is can you use the List interface for a parameter in an Axis web service method, or can only ArrayList be used? The gory details follow...
I have a axis beta 1 web service published that declares (among others) the following method and talks to a session EJB:
public List modifySubProfiles(String parentProfileType, String subProfileType,
Map parentIds, List newSubProfiles) throws RemoteException {
}
I have a test case where:
Map parentIds is declared as a Map and its underlying type is a HashMap
List subserviceStubs is declared as a List but its underlying type is an ArrayList
And my call parameters and invoke look like:
call.addParameter("parentProfileType",
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.PARAM_MODE_IN);
call.addParameter("subProfileType",
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.PARAM_MODE_IN);
call.addParameter("parentIds",
org.apache.axis.encoding.XMLType.SOAP_MAP,
javax.xml.rpc.ParameterMode.PARAM_MODE_IN);
call.addParameter("newSubProfiles",
org.apache.axis.encoding.XMLType.SOAP_ARRAY,
javax.xml.rpc.ParameterMode.PARAM_MODE_IN);
call.setReturnType(org.apache.axis.encoding.XMLType.SOAP_ARRAY);
Object[] ret = null;
ret = (Object[]) call.invoke(new Object[]{"package", "subservice", parentIds, subserviceStubs});
This test throws an IllegalArgumentException with the following stack trace:
[junit] Testcase: testModifySubProfiles(espial.ds.server.soap.servicetest.Ax
isServiceTest):: Caused an ERROR
[junit] java.lang.IllegalArgumentException: argument type mismatch on object
"espial.ds.server.soap.service.Service", method name "modifySubProfiles", tried
argument types: java.lang.String, java.lang.String, java.util.HashMap, [Ljava.
lang.Object;
[junit] java.lang.IllegalArgumentException: argument type mismatch on object
"espial.ds.server.soap.service.Service", method name "modifySubProfiles", tried
argument types: java.lang.String, java.lang.String, java.util.HashMap, [Ljava.
lang.Object;
[junit] at org.apache.axis.message.SOAPFaultBuilder.endElement(Unknown S
ource)
[junit] at org.apache.axis.encoding.DeserializationContextImpl.endElemen
t(Unknown Source)
[junit] at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1
515)
[junit] at org.apache.crimson.parser.Parser2.content(Parser2.java:1766)
[junit] at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1
494)
[junit] at org.apache.crimson.parser.Parser2.content(Parser2.java:1766)
[junit] at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1
494)
[junit] at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:
500)
[junit] at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
[junit] at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.j
ava:433)
[junit] at javax.xml.parsers.SAXParser.parse(SAXParser.java:357)
[junit] at org.apache.axis.encoding.DeserializationContextImpl.parse(Unk
nown Source)
[junit] at org.apache.axis.SOAPPart.getAsSOAPEnvelope(Unknown Source)
[junit] at org.apache.axis.client.Call.invoke(Unknown Source)
[junit] at org.apache.axis.client.Call.invoke(Unknown Source)
[junit] at org.apache.axis.client.Call.invoke(Unknown Source)
[junit] at org.apache.axis.client.Call.invoke(Unknown Source)
[junit] at espial.ds.server.soap.servicetest.AxisServiceTest.testModifyS
ubProfiles(AxisServiceTest.java:316)
[junit] at java.lang.reflect.Method.invoke(Native Method)
[junit] at junit.framework.TestCase.runTest(TestCase.java:166)
[junit] at junit.framework.TestCase.runBare(TestCase.java:140)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
[junit] at junit.framework.TestResult.runProtected(TestResult.java:124)
[junit] at junit.framework.TestResult.run(TestResult.java:109)
[junit] at junit.framework.TestCase.run(TestCase.java:131)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:173)
[junit] at junit.framework.TestSuite.run(TestSuite.java:168)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.
run(JUnitTestRunner.java:231)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.
main(JUnitTestRunner.java:409)
[junit]
[junit] TEST espial.ds.server.soap.servicetest.AxisServiceTest FAILED
However, the kicker is if I change my web service method to define the parameter newSubProfiles as an ArrayList instead of a List, everything works. Can you use the List interface in an Axis web service, or can only ArrayList be used? Or is there something else I am doing wrong here?
I know List objects are currently getting returned as ArrayLists, but must it be that way for method calls to the service as well?? I've also tried declaring subserviceStubs as an ArrayList and leaving the method parameter in the service declared as List, but that didn't work either. I have a number of other methods in the web service and everything seems to be working so far except the ability to declare a List as a parameter in one of its methods - only ArrayList seems to work, which would be a little annoying as we are trying to define interfaces for our services (and underlying beans) using Maps and Lists.
Thanks,
Martin
