我创建了 WSDL 文件,并在 WS Client 类中尝试将 HashMap 作为参数发送,如下所示:
HashMap<String, ArrayList<User>> map = new HashMap<String, ArrayList<User>>();
VerifyStub stub = new VerifyStub();
Verify vu = new Verify();
vu.setHmap(map);
并且遇到上述错误消息“java.util.HashMap 无法转换为 org.apache.axiom.om.OMElement”。
请问我是否可以将 HashMap 转换为 OMElement。
最佳答案
您无法通过 wsdl 接口(interface)传递像 HashMap 这样的集合。
wsdl 中没有集合类型的映射。
传递此类内容的最佳选择是传递数组。这可能意味着需要一层额外的包装代码来将数据传送到 Web 服务层。
此链接虽然不完全是您的情况,但它为在 wsdl 中使用集合提供了一些线索,
http://www.ibm.com/developerworks/webservices/library/ws-tip-coding/index.html
关于java.util.HashMap 无法转换为 org.apache.axiom.om.OMElement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9184310/