简体   繁体   中英

How to generate SOAP client code that uses dynamic location for WSDL?

I am using wsimport to generate client code for several WSDLs that are served by my application. I have to run the app in several different places. I am trying to simplify my client code generation/management problem.

What I have sort of slid back into is this. I have 3 interfaces and the app is installed in 3 places. At this point, I have to generate 9 source bundles. I also have 3 source directories, having driver code for each interface.

So, I have:

 src/srvr1.intf1/
 src/srvr1.intf2/
 src/srvr1.intf3/
 src/srvr2.intf1/
 src/srvr2.intf2/
 src/srvr2.intf3/
 src/srvr3.intf1/
 src/srvr3.intf2/
 src/srvr3.intf2/
 src/all.intf1
 src/all.intf2
 src/all.intf3

You can see how bad this is going to get when I have to move it up to over a dozen sites.

One thing that has occurred to me is that I can go into the generated code and replace the hard-coded WSDL locations with System.getProperty("currentWSDL") and I can set this at run-time. SO, I got from 12 to 6.

I can use introspection in the "all" code to make it so that that is one class. This gets me to 4. And adding a server does not increase that number.

So, as far as I can see, if I go in and change the WSDL references to a property look-up, then I have to re-do that every single time I run wsimport. Does this make sense?

Is there some way to get wsimport to use a property-read instead of a hard-coded string for the WSDL? I can even give it a value of the WSDL when I run wsimport. I just do not want to have to maintain n copies of the all 30+ client classes for n servers that are running the exact same app.

You can set your service url like this. there is no need for generating wsdl client for different server deployment unless it is changed. You generate proxy and then in every client read url from any resource ( local file , database ...) and set url like this

String url = //read url from config file or any other resoure like db ((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM