开发者

Accessing identical web services using the same client

开发者 https://www.devze.com 2022-12-27 11:22 出处:网络
I have some web services and I am creating a web client using ws-import. When creating the client I have this line:

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 t开发者_开发问答he 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号