views:

24

answers:

1

After implementing a test solution described here :

http://stackoverflow.com/questions/2158175/use-maven-to-trigger-a-wsgen-wsimport-in-a-row-using-wsdllocation

I wonder if there is a way to generate the client jar without knowing the WS URL, so that it would be usable against any similar ws deployed somewhere else.

Any idea?

+1  A: 

I wonder if there is a way to generate the client jar without knowing the WS URL, so that it would be usable against any similar ws deployed somewhere else.

Whatever WSDL URI has been used to generate the JAX-WS client artifacts, you can override a service endpoint address from the client code by using the appropriate constructor:

...
URL newEndpoint = new URL("http://new/endpointaddress?wsdl");
QName serviceName = new QName("http://targetNamespaceURI","EchoService"); 

EchoService service = new EchoService(newEndpoint, serviceName);
Echo port = service.getEchoPort();

System.out.println("Server said: " + echo.echo(args[0]));
...

Related question

See also

Pascal Thivent
Thanks! works great
ben
@ben You're welcome, glad the problem is solved.
Pascal Thivent