web-services - wsimport 如何从 WSDL 为 http :binding GET/POST 创建 Web 服务客户端

标签 web-services wsdl wsimport

我有 wsdl,并使用 wsimport 工具创建类。 SOAP 消息一切正常,但对于 http:binding GET/POST 我得到错误。 WSDL 的一部分如下:

<wsdl:binding name="DictServiceHttpPost" type="tns:DictServiceHttpPost"> 
    <http:binding verb="POST" /> 
...
...
...
<wsdl:port name="DictServiceHttpGet" binding="tns:DictServiceHttpGet"> 
      <http:address location="http://services.aonaware.com/DictService/DictService.asmx" /> 
    </wsdl:port> 
    <wsdl:port name="DictServiceHttpPost" binding="tns:DictServiceHttpPost"> 
      <http:address location="http://services.aonaware.com/DictService/DictService.asmx" /> 
</wsdl:port>

wsimport 生成类,对于 SOAP 端口它的工作,但对于 GET/POST 但是当我使用它们时,我收到错误。
Caused by: com.sun.xml.internal.ws.model.RuntimeModelerException: runtime modeler error: SEI invoker.DictServiceHttpPost has method match annotated as BARE but it has more than one parameter bound to body. This is invalid. Please annotate the method with annotation: @SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
    at com.sun.xml.internal.ws.model.RuntimeModeler.validateDocBare(RuntimeModeler.java:1247)
    at com.sun.xml.internal.ws.model.RuntimeModeler.processDocBareMethod(RuntimeModeler.java:1236)
    at com.sun.xml.internal.ws.model.RuntimeModeler.processMethod(RuntimeModeler.java:609)
    at com.sun.xml.internal.ws.model.RuntimeModeler.processClass(RuntimeModeler.java:401)
    at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:240)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:687)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:675)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:330)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:313)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:295)
    at javax.xml.ws.Service.getPort(Service.java:92)
    at invoker.DictService.getDictServiceHttpPost(DictService.java:124)
    ... 29 more
com.sun.xml.internal.ws.model.RuntimeModelerException: runtime modeler error: SEI invoker.DictServiceHttpPost has method match annotated as BARE but it has more than one parameter bound to body. This is invalid. Please annotate the method with annotation: @SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)

最佳答案

这发生在我身上,问题是我在服务实现中有一个公共(public)方法,它有多个参数,但这个方法不是服务操作。标有:SOAPBinding.ParameterStyle.BARE 的服务应该只有一个参数的公共(public)方法。我的解决方案是将此方法标记为私有(private),因为我是通过服务的一种公共(public)方法(操作)使用它。

确保您的服务实现中没有任何具有多个参数的公共(public)方法。

关于web-services - wsimport 如何从 WSDL 为 http :binding GET/POST 创建 Web 服务客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2583767/

相关文章:

json - RESTful Web 服务 url html 与 json

web-services - 如何在生产中处理 SSL 服务器证书?

c# - 如何为服务引用指定 Web 代理?

java - 带有 http :binding 的 wsimport

java - wsimport : unable to rename the package name

java - cxf 端点的 Spring 基本身份验证?

ruby-on-rails - 无法找到 SOAP 操作 RAILS + SAVON

wsdl - 将 Web 服务请求参数设为必填字段

python - 从现有 WSDL 构建 Django WebService

java - wsimport (xjc) - 为什么列表 getter 总是进行 null 检查?