Is ArrayList supported in Apache Axis Web service?
I have written a simple HelloWorld web service. Which takes an ArrayList as parameter. Code is as simple as `import java.util.ArrayList;
public class Service {
public void service(ArrayList<Object> list) {
System.out.println("Hello World..");
}
}`
I am using Eclipse Helios SR1 and trying to geneate the Web service.
Selecting Webservice Implementation to "Service" and Selecting Server runtime as Tomcat 6.0 and webservice runtime as Apache Axis. Clicking on next gives warning as
The service class "Service"
does not comply to one or more requirements of the JAX-RPC 1.1
specification, and may n开发者_JS百科ot deploy or function correctly.
The method "service" on the service class "Service"
uses a data type, "java.util.ArrayList"
, that is not supported by the JAX-RPC specification. Instances of the type may not serialize or deserialize correctly. Loss of data or complete failure of the Web service may result.
Clicking ok to continue and it shows more warning one by one : The input type java.lang.Class is a non-instantiable type and will be omitted from the sample JSP. Continue with sample JSP generation?
The input type javax.xml.namespace.QName is a non-instantiable type and will be omitted from the sample JSP. Continue with sample JSP generation?
IWAB0189W The Sample JSP client omitted some methods because they contained unsupported types.
Any reason why it may be happening? I saw on Sun site : Sun RPC Doc
According to it ArrayList should be supported.
Any help?
It's really good practice to write the WSDL and then generate java classes using Axis WSDL2Java tool. You can always concentrate more on writing WSDL as per your business needs and leave all the hassle of marshaling and unmarshaling to generate classes.
As quoted from the specification.
Arrays
JAX-RPC also supports arrays with members of supported JAX-RPC types. Examples of supported arrays are int[] and String[]. Multidimensional arrays, such as BigDecimal[][], are also supported.
A simple modification of your method signature to accept an array as opposed to an ArrayList should fix the problem.
精彩评论