aspose file tools*
The moose likes Web Services and the fly likes How to change WSDL url dynamically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "How to change WSDL url dynamically" Watch "How to change WSDL url dynamically" New topic
Author

How to change WSDL url dynamically

Aj Maharaj
Greenhorn

Joined: Apr 22, 2012
Posts: 2

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;

___________________________________________________________________
Raghav Viswanathan
Greenhorn

Joined: Apr 26, 2012
Posts: 26

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


Better late than never.
Aj Maharaj
Greenhorn

Joined: Apr 22, 2012
Posts: 2

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

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to change WSDL url dynamically