• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to change WSDL url dynamically

 
Greenhorn
Posts: 2
Netscape Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to change WebServiceRef URL runtime specially IP(172.16.6.241) address only.
can any one help me

_______________________________________________________________

@WebServlet(name="ClientServlet", urlPatterns={"/ClientServlet"})
public class ClientServlet extends HttpServlet {
static long ReqCount = 1;
static int OldSec = 0;

@WebServiceRef(wsdlLocation="http://172.16.6.241:8080/CalculatorApp/CalculatorWSService?wsdl")

public CalculatorWSService service;

@Resource
protected WebServiceContext context;

___________________________________________________________________
 
Greenhorn
Posts: 26
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Aj Maharaj
Greenhorn
Posts: 2
Netscape Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Raghav
I will try This..in My Project

Raghav Viswanathan wrote: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

 
reply
    Bookmark Topic Watch Topic
  • New Topic