所以我有一段用 Java 生成 SOAP 服务的代码,通过 Tomcat/Axis2 服务器上的 Jython 包装了一些 Python 代码...并且它可以工作!
我有一个返回
的方法 public static List<MyClass> doSomething()
但从 Soap 答案中我只得到一些空数据:
<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 - Map , How do I send an array or collection of complex objects using web services in Java (e.g. Axis2)?很多人说不能得到List作为返回,而只能得到Array,
但是,我不明白,因为我注意到,如果我决定生成一个 List< String > 作为结果,上面的结果实际上是一个具有正确数量元素的空列表,然后我得到了正确的值(是因为我在 List 中使用了简单的 < String > Java 类型吗?),甚至没有对 Array 或 ArrayList 进行任何更改(虽然我已经读到 List 无法生成)
所以我可能错过了其他东西,有什么我可能忘记的技巧吗? 就像将我的 MyClass 更改为 java.io.Serilized 或提供一些可由 Axis2 使用的特定方法在我的 XML 输出 SOAP 流中拥有/生成正确的值?
是否可以通过 Axis2 进行回复并生成列表?
最佳答案
不,这是不可能的。您可以阅读此问题之前的回答 here .
就您而言,您将像这样返回:
public static MyClass[] doSomething()
让 List.toArray() 为您发挥魔力!
关于java - Axis2/SOAP,返回 List<myIObject> 产生空返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10883756/