Ignore missing method in JAX-WS client

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, the service is completed with an exception, for example, as follows (lines are added for clarity):

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 can this be ignored? I would like to be backward compatible when using a web service. As long as the methods are just added, this should work very well most of the time.

The problem occurs in the getPort method:

 Service s = Service.create( new URL("http://example.com/foo?wsdl"), new QName("http://example.com", "MyService")); MyService m = s.getPort(MyService.class); 
+4
source share
4 answers

Use local WSDL file:
The client application has a local WSDL file for the service, for example, inside the jar file.

You get it with

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

This worked for the application I wrote. Later, the server extended the optional WSDL attribute while the client still uses the local one.

+1
source

I simply deleted the webservice link and created it again using the interface.

0
source

Just for reference. You can also annotate a method with

 @WebMethod(exclude=true) 

This will mean that the method is ignored for comparison with wsdl.

0
source

The Service class contains a static constructor with the local variable of the wsdl file. Check if there is someNewMethod in the local wsdl file. If you do not download the wsdl file from the source Url and save it locally. The soap address location value at the end of wsdl is also important. Sometimes https refers to http.

0
source

Source: https://habr.com/ru/post/1445525/


All Articles