servicewsimportqnames

Accessing identical web services using the same client


I have some web services and I am creating a web client using ws-import.

When creating the client I have this line:

MyServiceService service = new MyServiceService();

It works fine as it is.

I have the same web service running on another server and I was wondering if I could access them using the same client. Is it possible to change the wsdl url of the client? Ctrl-Space in Eclipse gives me 2 parameters which I can enter into MyServiceService which are URL arg0 and Qname arg1. Is this what I'm looking for? And if this is the case what should I put in Qname since I didn't find any Javadoc associated and didn't find it on google neither

Thanks and regards, Krt_Malta


Solution

  • Yes, you can do this. As you suspected, you need to use the constructor with this signature that is generated on your service class. As you can see, it takes two arguments: a QName, and an Url.

    The QName is a little bit tricky to determine. You have to look at the generated source code for the no-arg constructor of your service class (and the @Service attribute on the class). If you do this, you should be able to figure what QName the no-arg constructor uses. Just construct a QName with those same values, and use that.

    The Url is easy: just use the wsdl url you want to access.