我创建了 WSDL 文件,并在 WS Client 类中尝试将 HashMap 作为参数发送,如下所示:
HashMap> map = new HashMap>();
verifyStub存根=新的VerifyStub();
验证 vu = new verify();
vu.setHmap(map);
并且遇到上述错误消息“java.util.HashMap 无法转换为 org.apache.axiom.om.OMElement”。
我想知道是否可以将 HashMap 转换为 OMElement。
I created WSDL file and in the WS Client class am trying to send HashMap as the parameter as follows :
HashMap<String, ArrayList<User>> map = new HashMap<String, ArrayList<User>>();
VerifyStub stub = new VerifyStub();
Verify vu = new Verify();
vu.setHmap(map);
And am experiencing the above error message "java.util.HashMap cannot be cast to org.apache.axiom.om.OMElement".
May I know, whether I can convert HashMap to OMElement.
发布评论
评论(1)
您无法通过 wsdl 接口传递像 HashMap 这样的集合。
wsdl 中没有集合类型的映射。
传递这样的东西的最佳选择是传递数组。这可能意味着需要一层额外的包装器代码来将数据传送到 Web 服务层。
此链接虽然不完全是您的情况,但它对在 wsdl 中使用集合提供了一些启发,
http://www.ibm.com/developerworks/webservices/library/ws-tip-coding/index.html
You can't pass Collections like HashMap through a wsdl interface.
There is no mapping of collection types in wsdl.
Your best bet for passing things like that is to pass Arrays. This may mean an extra layer of wrapper code to bring your data out to the webservice layer though.
This link, whilst not exactly your case throws some light on using collections in a wsdl,
http://www.ibm.com/developerworks/webservices/library/ws-tip-coding/index.html