Skip to main content

make JAX-WS work with endpoint changes

2 replies [Last post]
ciro_rezende
Offline
Joined: 2007-07-20

Hi dear fellows!

Sorry for the poor english (i´m brazilian). I´d like to ask a question:

Let´s suppose that I have a Web Service in a Production environment.

I get it´s WSDL and use wsimport to generate artifacts to build a client application.
Ok ´till there, the client works fine and the web service is consumed.

Now let´s say that I have exactly the SAME web service, deployed in another server.

Just explaining, the endpoits point to :

http://foo.acme.com/services/SampleService
http://bar.acme.com/services/SampleService

So, as said before, I generated the client for the service at foo.acme.com, and it´s being used by several hundreds of aplications that use my client to consume the web service.

So now, let´s suppose that I need, for any reason, start comsuming the service at bar.acme.com (it´s the same service, just located elsewhere), abandoning foo.acme.com. The point is that many people are using the client to access the web service, and I can´t re-generate the artifacts and recompile and rebuild the client and re-distribute it to the people because the endpoit will change.

I know that I can build the client using Dispatch, but that´s not the point.

Do you know how can I dynamically change the endpoint to the web service without need to rebuild the artifacts?!?!

Any help would be appreciated!

Thanks in advance!!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ramapulavarthi
Offline
Joined: 2004-06-01

If you just want to change the endpoint address, you can do it it multiple ways.
When you instantiate the service class, pass the WSDL of the bar.acme.com service
like new HelloService(bar.acme.com_wsdl_location,bar.acme.com_service_qname);

or

Just change the ENDPOINT_ADDRESS_PROPERTY on the proxy.

((BindingProvider) proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,bar.acme.com_service_location)

See https://jax-ws.dev.java.net/guide/How_to_invoke_and_endpoint_by_overridi...

ciro_rezende
Offline
Joined: 2007-07-20

Orray! TKS for the help... it´s exaclty what I needed.

I did:

SampleService service = new SampleService(new URL(baseUrl, wsdlAddress), SERVICE_QNAME);
Sample servicePort = service.getSampleSoapPort();
String returnedString = servicePort.execute("Test Message");

Tks for the response!

Best regards,