java 忽略 JAX-WS 客户端中缺少的方法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13345328/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ignore missing method in JAX-WS client
提问by musiKk
I have a model that is used to create a Web Service endpoint on a server. The same model is used for the client. However when a new operation is added to the server but the client still uses the older model, service creation fails with an exception like the following (line breaks added for clarity):
我有一个用于在服务器上创建 Web 服务端点的模型。客户端使用相同的模型。但是,当向服务器添加新操作但客户端仍使用旧模型时,服务创建将失败并出现如下异常(为清晰起见添加了换行符):
Exception in thread "main" javax.xml.ws.WebServiceException:
Method someNewMethod is exposed as WebMethod, but there is no
corresponding wsdl operation with name someNewMethod in the
wsdl:portType{http://example.com}MyService
I understand the problem but is it possible to ignore this? I'd like to be backwards compatible when consuming the Web service. As long as methods are merely added this should work just fine most of the time.
我理解这个问题,但是否可以忽略这一点?我希望在使用 Web 服务时向后兼容。只要仅添加方法,这在大多数情况下应该可以正常工作。
The problem occurs in the getPort
method:
问题出现在getPort
方法中:
Service s = Service.create(
new URL("http://example.com/foo?wsdl"),
new QName("http://example.com", "MyService"));
MyService m = s.getPort(MyService.class);
回答by Hugo
Just for reference. You can also annotate the method with
仅供参考。您还可以使用
@WebMethod(exclude=true)
This will make sure the method is ignored for comparing with the wsdl.
这将确保在与 wsdl 进行比较时忽略该方法。
回答by Pekmezli Dürüm
Your Service class contains a static constructor with a local wsdl file variable. Check if local wsdl file has the someNewMethod. If not download the wsdl file from original Url and save to local. The soap address location value at the end of the wsdl is also important. Sometimes https turns to http.
您的 Service 类包含一个带有本地 wsdl 文件变量的静态构造函数。检查本地 wsdl 文件是否具有 someNewMethod。如果没有从原始 Url 下载 wsdl 文件并保存到本地。wsdl 末尾的soap 地址位置值也很重要。有时 https 会变成 http。
回答by AlexWien
Use an local WSDL File:
The client App has an local WSDL File of the service e.g inside the jar file.
使用本地 WSDL 文件:
客户端应用程序具有服务的本地 WSDL 文件,例如在 jar 文件中。
The you get it with
你得到的
URL wsdlURL = this.getClass().getClassLoader()
.getResource("MyWebService.wsdl");
That worked for a App that i wrote. The server later extended an additional WSDL attribute, while the client still uses the local one.
这适用于我编写的应用程序。服务器后来扩展了一个额外的 WSDL 属性,而客户端仍然使用本地的。
回答by jessicathaisa
I just deleted the webservice reference and created again using the interface.
我刚刚删除了 webservice 引用并使用该接口重新创建。