Axis2 / SOAP,返回List <myiobject>产生空返回</myiobject>

时间:2012-06-04 15:19:29

标签: java soap axis2

所以我有一段用Java生成SOAP服务的代码,通过Tomcat / Axis2服务器通过Jython包装一些Python代码......它有效!

我有一个返回

的方法
   public static List<MyClass> doSomething()

但是从肥皂回答中我只得到一些空数据:

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Body>
      <ns:doMyServiceResponse xmlns:ns="http://mypyinterface" xmlns:ax23="http://mypyinterface/xsd">
     <ns:return xsi:type="ax23:MyClass" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
     <ns:return xsi:type="ax23:MyClass" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
     <ns:return xsi:type="ax23:MyClass" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
     <ns:return xsi:type="ax23:MyClass" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
     <ns:return xsi:type="ax23:MyClass" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
     <ns:return xsi:type="ax23:MyClass" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
     <ns:return xsi:type="ax23:MyClass" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
      </ns:doMyServiceResponse >
   </soapenv:Body>
</soapenv:Envelope>

我在网上找到了很多关于这个主题的帖子,例如 complex types in axis2 - MapHow do I send an array or collection of complex objects using web services in Java (e.g. Axis2)?,很多人说无法获得列表作为回复,但只有阵列

但是,我不明白,因为我注意到上面的结果实际上是一个空的List,有正确的元素数,如果我决定生成 List&lt;结果是字符串&gt; ,然后我得到了正确的值(是因为我在List中使用了一个简单的&lt; String&gt; Java类型?),甚至没有更改任何内容到Array或ArrayList(虽然我已经读过列表无法生成)

所以我可能错过了其他的东西,有没有我可能忘记的伎俩? 比如将我的MyClass更改为java.io.Serilizable或者提供一些特定的方法,Axis2可以使用这些方法在我的XML输出SOAP流中产生/产生正确的值?

是否可以通过Axis2进行回复,否则会生成一个List?

1 个答案:

答案 0 :(得分:1)

不,这是不可能的。您可以阅读此问题的先前答案here

在你的情况下,你会这样回来:

public static MyClass[] doSomething()

让List.toArray()为你做神奇的事!