How to change the endpoint of a webservice url?

I created a web service client using the JBoss utilities (JAX-WS compatible) using the Eclipse web service client from wsdl '.

So the only thing I have provided is the WSDL URL of the web service.

The web service provider is now telling me to change the "client endpoint access URL" of the web service.

What is it and how to change it?

+96
java web-services jboss jax-ws
Mar 22 '10 at 8:15
source share
4 answers

IMO, the provider tells you to change the endpoint of the service (that is, where you can get to the web service), and not the endpoint of the client (I don’t understand what it can be). To change the endpoint of a service, you basically have two options.

Use the Binding Provider to set the endpoint URL

The first parameter is to change the value of the BindingProvider.ENDPOINT_ADDRESS_PROPERTY property for BindingProvider (each proxy implements the javax.xml.ws.BindingProvider interface):

 ... EchoService service = new EchoService(); Echo port = service.getEchoPort(); /* Set NEW Endpoint Location */ String endpointURL = "http://NEW_ENDPOINT_URL"; BindingProvider bp = (BindingProvider)port; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL); System.out.println("Server said: " + echo.echo(args[0])); ... 

The downside is that this only works when the original WSDL is available. Not recommended.

Use WSDL to get the endpoint URL

The second option is to get the endpoint URL from the WSDL.

 ... URL newEndpoint = new URL("NEW_ENDPOINT_URL"); QName qname = new QName("http://ws.mycompany.tld","EchoService"); EchoService service = new EchoService(newEndpoint, qname); Echo port = service.getEchoPort(); System.out.println("Server said: " + echo.echo(args[0])); ... 
+162
Mar 22 '10 at 8:59
source share

To add some clarification, when you create your service, the service class uses the standard wsdlLocation, which was inserted into it when the class was built from wsdl. Therefore, if you have a service class named SomeService, and you create an instance similar to the following:

 SomeService someService = new SomeService(); 

If you look inside SomeService, you will see that the constructor looks like this:

 public SomeService() { super(__getWsdlLocation(), SOMESERVICE_QNAME); } 

So, if you want it to point to a different URL, you simply use a constructor that takes a URL argument (there are also 6 constructors for setting qname and functions). For example, if you configured a local TCP / IP monitor that listens on port 9999, and you want to redirect to this URL:

 URL newWsdlLocation = new URL("http://theServerName:9999/somePath"); SomeService someService = new SomeService(newWsdlLocation); 

and this will call this constructor inside the service:

 public SomeService(URL wsdlLocation) { super(wsdlLocation, SOMESERVICE_QNAME); } 
+16
Mar 19 '15 at 23:31
source share

I would not go as far as @Femi to modify an existing address property. You can easily add new services to the definitions section.

 <wsdl:service name="serviceMethodName_2"> <wsdl:port binding="tns:serviceMethodNameSoapBinding" name="serviceMethodName"> <soap:address location="http://new_end_point_adress"/> </wsdl:port> </wsdl:service> 

This does not require recompiling WSDL for Java, and creating updates is no more difficult than if you used the BindingProvider option (which, by the way, didn’t work for me).

+1
Dec 27 '18 at 16:10
source share

To change the property of the final address, edit the wsdl file

 <wsdl:definitions....... <wsdl:service name="serviceMethodName"> <wsdl:port binding="tns:serviceMethodNameSoapBinding" name="serviceMethodName"> <soap:address location="http://service_end_point_adress"/> </wsdl:port> </wsdl:service> </wsdl:definitions> 
-5
Nov 09 '13 at 10:10
source share



All Articles