wsimport how to create web service client from WSDL for http:binding GET/POST

淺唱寂寞╮ 提交于 2019-12-06 06:10:59

问题


I have wsdl and I create classes with wsimport tool. Everything is going ok for SOAP messages but for http:binding GET/POST I get error. Part of the WSDL follows:

<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 generates classes, for SOAP port its working but for GET/POST but when I use them, I receive error.

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)

回答1:


This happened to me, the problem was that I had a public method in the service implementation, that had more than one parameter but this method was not a service operation. Services marked with: SOAPBinding.ParameterStyle.BARE should only have public methods with only one parameter. My solution was mark this method as private since I was using it from one public method of the service (operation).

Make sure you don't have any public method in your service implementation that has more than one parameter.



来源:https://stackoverflow.com/questions/2583767/wsimport-how-to-create-web-service-client-from-wsdl-for-httpbinding-get-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!