Skip to main content

Customize IP and port on a WS client created by wsimport

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2011-08-25


I've developed a WS using JAX-WS and am creating the consuming client automatically via wsimport. Works fine. Now when I run the WS on different servers and sometimes even need to change ports depending on which ports are already used on these servers, I would like to create a config file that the client reads before it starts so it knows to which IP and port to connect to the WS server. But I don't see how I could customize this in the pre-build code from wsimport:


class MyServiceextends Serviceprivate final static URL MYSERVICE_WSDL_LOCATION;private final static Logger logger = Logger.getLogger(test..MYService.class.getName());static {null;try {class.getResource(".");new URL(baseUrl, "");catch (MalformedURLException e) {logger.warning("Failed to create URL for the wsdl Location: '', retrying as a local file");logger.warning(e.getMessage());MYSERVICE_WSDL_LOCATION = url;public MYService(URL wsdlLocation, QName serviceName) {super(wsdlLocation, serviceName);

The IP and port are defined in a static field and within the constructor I'm not allowed to read a config file to set the IP/Port before I call the "super" method... Thanks! Kurt


URL url =

URL baseUrl;

baseUrl = test.MYService.

url =





Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2011-08-25

Sorry, I just saw that my post looks really messy! I just copy-pasted code from eclipse and didn't realize that it would format that badly within this text box :(
Basically, my issue is that the line where the IP and port which my web service should be contacted at is written as a static field :
static { URL(baseUrl,}
Then there is the constructor which immediately must call its super-constructor:
public MYService(URL wsdlLocation, QName serviceName) {super(wsdlLocation, serviceName);
The variable "wsdlLocation" is built using the statically defined ip and port above - how can I modify these settings dynamically based on a config file? I cannot read the config file during the "static {... }" block and within the constructor it's too late as the first thing the constructor must do is call its super which needs the ip and port pre-loaded into the URL object...