You can use a BindingProvider.ENDPOINT_ADDRESS_PROPERTY
and set the endpoint you want on the client proxy as such
((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
http://www.the.endpoint/foo);
Hope that helps,
Kathy
----- Original Message -----
From: Maverick Merritt <mmerritt_at_usgs.gov>
> Hello,
>
> How can I change the endpoint programmatically? For example, I am
> writing
> a command line application in
> Java that needs to talk to a Web Service using Netbeans IDE. I
> create
> client stubs using wsimport pointing
> to the WSDL file from the server that is provided by the Web
> Service.
>
> The folks that provide the Web Service actually provide two Web
> Services
> that have the same exact Interface,
> one for testing and another for production. I want to point to
> either
> one. I don't want to have to create
> two sets of client stubs, for each WSDL. I want to create a
> single copy
> of the client stubs and just change the
> endpoint via the command line. Also, I would like to do some
> interoperability tests using the WSI
> interoperability tools. These tools act as a man in the middle
> where you
> direct the client to use the
> host and port of the WSI monitor service.
>
> With JAX-WS, It seems that it "embeds" the endpoint (taken from the
> WSDL
> file) down in the generated client
> stubs. This is fine if I always want to talk to that single server
> for
> the rest of the application's life. What if they
> moved? They provide the same API, so why recreate the client stubs
> again?
> What if you wanted to do load
> balancing?
>
> I cannot find a simple or reasonable way to programmatically change
> the
> endpoint. Can anyone please help?
>
> Sincerely,
> Maverick Merritt
>