I have a setup in which a 'scheduler' sends requests to different webservices. The interfaces for those webservices are the same, although they perform slightly different tasks. I wrote a general wsdl file which I would like to use for all those services. So I use a wsimport to generate a client. All is good so far. I should be able to do something like:
Unfortunately, I cannot find how to just change the url of a webservice. I can give parameters to MyService in the form of a 'wsdl location', a Qname and WebServiceFeatures, but not a different url. If I try to skip the generated MyService class and look in Service.create(), I still can't find the place where to add the new address of the endpoint. I can add 'endpoints' but then I can only make 'Dispatch' objects which seems to operate at a lower lever than I would like. I also couldn't find clues in the source code.
Did I miss something obviouss or is it really not done to use the same WSDL to generate clients for different web-services with the same contract?
You set the BindingProvider.ENDPOINT_ADDRESS_PROPERTY property in the request context prior to sending a request.
The following example shows how to set the property when working with an object implementing the Dispatch interface:
Here is an example how to set this property when working with generated stubs: