以Hasmap作为输入参数的基于SOAP的Webservice接口 [英] SOAP based Webservice Interface with Hasmap as Input Parameter

查看:425
本文介绍了以Hasmap作为输入参数的基于SOAP的Webservice接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图构建一个基于SOAP的web服务,它将Hashmap作为使用Java的输入?



有没有人试过它?这可能会导致什么样的问题?

处理输入为Hashmap或List的最佳做法是什么?



感谢答案

解决方案

在CXF java_first_jaxws样品:



HTTP://svn.apache。 org / repos / asf / cxf / trunk / distribution / src / main / release / samples / java_first_jaxws /

提供了关于如何正常使用JAX-WS / JAXB处理Maps(以及其他接口派生类型)。基本上,您必须创建一个XmlAdapter,它将地图转换为JAXB可以完全映射的类型。然后JAXB会在运行时自动使用这些适配器来映射它感到满意的类型。结果是,您可以完全控制生成的schema / wsdl(因此您不必拥有通用的key和value元素名称),同时也可以方便地使用地图。


I am trying to build a SOAP based webservice which will have Hashmap as input using Java?

Has anyone tried it before? What kind of problems this might cause?

WHat is the best practice for handling input as Hashmap or List?

Thanks for answer.

解决方案

The CXF java_first_jaxws sample:

http://svn.apache.org/repos/asf/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/

provides and example on how to "properly" handle Maps (and other interface derived types) with JAX-WS/JAXB. Basically, you have to create a XmlAdapter that will convert the map into types that JAXB can completely map. JAXB will then automatically use those adapters at runtime to map to the types it is happy with. The result it that you have complete control over the resulting schema/wsdl (so you don't have to have the generic "key" and "value" element names) yet also get the convenience of getting to use the Maps.

这篇关于以Hasmap作为输入参数的基于SOAP的Webservice接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆