Link to home
Start Free TrialLog in
Avatar of Compmind
Compmind

asked on

How can I change the end point of a Web Service Client in NetBeans 6.1 at runtime?

I am using NetBeans 6.1 to construct a console application using JAX-WS to generate code to consume a Web Service. How can I change the url of the end point for the web service at runtime? It would be preferable to be set in an xml configuration file.

Thanks in advance
Avatar of Siva Prasanna Kumar
Siva Prasanna Kumar
Flag of India image

Avatar of Compmind
Compmind

ASKER

I was able to change where it queries the web service but not from where it downloads the wsdl file
Didn't get you, Generally we change the end points when the server IP address is changed or when the same service available at different IP.

if the WSDL location and service location are generally same but they are not must to be same. Please clarify what changes you meant.
ok I want to be able at runtime to change the WSDL location and the service location both at the same time.
do u have the service hosted at multiple locations? if its the same WSDL then service location change will do.

Can you share some source code which has the wsdl location in it.

This code will change the service location but not the WSDL location and the service is hosted at different locations(development and production)  but the locations cannot communicate with each other. So it wouldn't work if I can only change the service location because it would try to download the WSDL from the development location which is not accesible from the production location.
  private static void logOut(int sessionID){
          try {
             int sid = sessionID;
                com.ca.unicenterserviceplus.servicedesk.USDWebService service = new com.ca.unicenterserviceplus.servicedesk.USDWebService();
   com.ca.unicenterserviceplus.servicedesk.USDWebServiceSoap port = service.getUSDWebServiceSoap();
   ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endPointURL);
//endPointURL is a string
      port.logout(sid);
        } catch (Exception ex) {
             ex.printStackTrace();
        }
   
  }

Open in new window

you have used WSDL only for creation of Client stubs and thats it. I don't think it will download WSDL every time, once the stubs are created based on the endpoint (generally derived from WSDL , in your case you are overriding manually) the service will be invoked appropriately.

if u have to change the WSDL it self then u must recreated the stubs with the new WSDL.
Well in netbeans it does download the WSDL I do not why but it does it

I get the following error

javax.xml.ws.WebServiceException: Failed to access the WSDL at: http://192.168.10.71:8080/axis/services/USD_R11_WebService?WSDL. It failed with:

Connection timed out: connect.
Try opening the same link in browser and see

http://192.168.10.71:8080/axis/services/USD_R11_WebService?WSDL

it look like wsdl location  is incorrect.
ASKER CERTIFIED SOLUTION
Avatar of Compmind
Compmind

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial