忽略JAX-WS客户端中缺少的方法

问题描述 投票:4回答:4

我有一个模型用于在服务器上创建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

我理解这个问题,但有可能忽略这个吗?我希望在使用Web服务时能够向后兼容。只要添加方法,这应该在大多数情况下都能正常工作。

问题出现在getPort方法中:

Service s = Service.create(
    new URL("http://example.com/foo?wsdl"),
    new QName("http://example.com", "MyService"));
MyService m = s.getPort(MyService.class);
java soap jax-ws
4个回答
1
投票

仅供参考。您还可以使用注释方法

@WebMethod(exclude=true)

这将确保忽略该方法以与wsdl进行比较。


0
投票

使用本地WSDL文件: 客户端App具有服务的本地WSDL文件,例如在jar文件中。

你明白了

URL wsdlURL = this.getClass().getClassLoader()
                .getResource("MyWebService.wsdl");

这适用于我写的应用程序。服务器稍后扩展了另一个WSDL属性,而客户端仍然使用本地属性。


0
投票

我刚删除了Web服务引用,并使用该界面再次创建。


0
投票

您的Service类包含一个带有本地wsdl文件变量的静态构造函数。检查本地wsdl文件是否具有someNewMethod。如果没有从原​​始Url下载wsdl文件并保存到本地。 wsdl末尾的soap地址位置值也很重要。有时https转为http。

© www.soinside.com 2019 - 2024. All rights reserved.