We have WSDL files which are stubs generated from a .net system which has published webservices. we as webservices client are generating the java client proxies and ivoking the transaction. My question is that they are going to publish the services in Development server, QA Server and so on till we get to production. So i do not want to regenerate proxies for each environment. I want to keep the address to invoke this services as variable which can be changed. Please suggest. Iam very close to my dead line.
Be sure to use a ServiceLocator to gain access to your proxy (your proxy generator probably created one for you). Assuming that you're deploying to a J2EE container, you can set up a JNDI reference that maintains the appropriate URL to the webservice. This way, the maintenance of the URL's is a deployment task and can easily be changed for each environment (or modified if the webservice provider moves).
In pseudocode, your code will look something like this:
URL url = (URL) jndiContext.lookup("url/webserviceURL");
WSProxy proxy = serviceLocator.getProxy(url);
Thanks jeff. My source is a WSDL file which is from a .net system and i generate a webservice client a javaproxy. service locator is not generated. I will search for sample code for service locator and use it. Also i have to find information on setting up JNDI configurations for the webservices.
it generates service locator and iam able to use the approach successfully. But further more i had investigated and found out a way to isolate to deal with SOAP directly by using WSIF componets so in the future the services changes we do not have to regenerate the proxies but we can just update the WSDL files in the project and still use WSIF components.
Generally most proxy client generators provide some way by which to change the endpoint you are using. If you are using axis, one of your generated classes will be called something like *Locator. This is just an example, but it should be something like the following:
// obtain an instance of this class
ExternalSignInLocator locator = new ExternalSignInLocator();
// set endpoint address (END Point URL is what you need to change)
// get a web service client instance
ExternalSignInSoap_PortType soap = locator.getExternalSignInSoap();
// execute the web service
dpResponse = soap.execute(dpRequest);