我正在尝试使用具有 HashMap 作为其参数之一的 JBossWS 3.1.2 开发 Web 服务。我正在使用这个版本的 JBossWS,因为这是与我正在使用的 JBoss 版本一起分发的。我正在使用 wsprovide 来生成 WSDL,并使用 wsconsume 来创建 WS 客户端存根。
我的 WebService 的简化版本是:
@WebService(targetNamespace = "http://localhost/ping", serviceName = "Ping")
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class Ping {
@WebMethod
@WebResult(name="result")
public String ping(@WebParam(name="arguments") HashMap arguments) {
return "pong";
}
}
wsprovide 创建的 WSDL 包含:
<types>
<xs:schema targetNamespace='http://localhost/ping' version='1.0' xmlns:tns='http://localhost/ping' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:complexType name='hashMap'>
<xs:complexContent>
<xs:extension base='tns:abstractMap'>
<xs:sequence/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType abstract='true' name='abstractMap'>
<xs:sequence/>
</xs:complexType>
</xs:schema>
</types>
生成的客户端代码包含一个空抽象类 AbstractMap.java 和一个空类 HashMap。
我本来希望生成类似于以下内容的 WSDL:
<complexType>
<sequence>
<element name="key" type="anyType" />
<element name="value" type="anyType" />
</sequence>
</complexType>
我还尝试使用自定义类 (ParameterMap) 包装 HashMap,但只是得到了更多相同的东西。
有没有我没有看到的下一步?我是否遗漏了什么,或者这是对使用 JBossWS 开发 Web 服务的自下而上方法的限制?