Apache Axis Web 服务是否支持 ArrayList?
我编写了一个简单的 HelloWorld Web 服务。它采用 ArrayList 作为参数。代码就像“import java.util.ArrayList;”一样简单
public class Service {
public void service(ArrayList<Object> list) {
System.out.println("Hello World..");
}
}`
我正在使用 Eclipse Helios SR1 并尝试生成 Web 服务。 将 Webservice 实现选择为“Service”,并将服务器运行时选择为 Tomcat 6.0,将 Webservice 运行时选择为 Apache Axis。单击下一步会发出警告: 服务类“Service”
不符合JAX-RPC 1.1
规范的一项或多项要求,并且可能无法正确部署或运行。 服务类"Service"
上的方法"service" 使用JAX-RPC 规范不支持的数据类型"java.util.ArrayList"
。该类型的实例可能无法正确序列化或反序列化。可能会导致数据丢失或 Web 服务完全失败。
单击“确定”继续,它一一显示更多警告: 输入类型 java.lang.Class 是不可实例化的类型,将从示例 JSP 中省略。继续生成示例 JSP 吗?
输入类型 javax.xml.namespace.QName 是不可实例化的类型,将从示例 JSP 中省略。继续生成示例 JSP 吗?
IWAB0189W 示例 JSP 客户机省略了一些方法,因为它们包含不受支持的类型。
有什么原因可能会发生这种情况吗? 我在Sun网站上看到: Sun RPC Doc
根据它ArrayList应该支持。
有什么帮助吗?
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 not 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编写 WSDL 然后使用 Axis WSDL2Java 工具生成 java 类确实是一个很好的做法。您始终可以更加专注于根据业务需求编写 WSDL,而将所有编组和解编组的麻烦留给生成类。
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.
正如规范中引用的那样。
对方法签名进行简单修改以接受数组而不是 ArrayList 应该可以解决问题。
As quoted from the specification.
A simple modification of your method signature to accept an array as opposed to an ArrayList should fix the problem.