posted 12 years ago
Hello Maharaj,
I assume that the question posed here is to dynamically choose the end point of the webservice.
The scenarios here is . Let us assume that I have a service which prints Hello world along with your name when invoked. The following would be the steps.
1. Deploy the service at end point A and end point B.
2. Use wsimport command to create the client files needed for invoking the service from any one of the end points.
3. use the following piece of code
URL url = new URL("http://localhost:9999/ws/SayHello?wsdl"); // Note you can change the URL here to call different endpoints which host the service
QName qname = new QName("http://ws.hellowservice.com/", "HelloWorldServiceImpl"); // refers to the TNS name and the service Name as given in the WSDL file
//1st argument service URI
//2nd argument is service name
Service service = Service.create(url, qname);
// Please note that you can also invoke create method whioch is overloaded with no argument. This will inturn use the endpoint that was used to generate the client files.
HelloWorldService helloWorldService = service.getPort(HelloWorldService.class);
System.out.println(helloWorldService.sayHello("Maharaj AJ"));
Hope this helps,... Do let me know if you still have doubts ... or if you would need any other implementations....
Thanks and regards
Raghav.V