JAX-WS: using local WSDL copy
If you need to create a web service from a local copy of the WSDL, which can happen if the remote system is not available or accessible, there are a number of options, mentioned on this page. I am in the situation where I have already created my web service client (using wsimport), so I need to resolve the service address at runtime. If the remote system can't be accessed (the current environment I'm working in has a proxy/firewall issue, so I can't get to the remote WSDL as I would normally like to), then my option is this:
1. create a jax-ws-catalog.xml file like the following:
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
<system systemId="http://remote.system.host.address:6666/ServiceName.asmx?WSDL"
uri="wsdl/ServiceName.wsdl"/>
</catalog>
The systemId will be the normal remote WSDL address that you would be using if you could. This is the WSDL that the web service client will be created using. The uri is the address of your local copy of the WSDL.
2. add that file to your build, directly underneath WEB-INF. This is where the JAX-WS code expects it to be. Not in the "classes" folder.
3. change your build to store the local WSDL copy inside the webapp in the "wsdl" folder. This is used by the uri attribute in the jax-ws-catalog.xml to point to your local copy of the WSDL.
4. redeploy. Now, when the web service client is created, it should not try to connect over the network to the remote WSDL, but will use the local version.
Don't forget to keep your local copy of the WSDL up to date! If you get a new version, make sure the build reflects it.
The jax-ws-catalog.xml can also be used to force your web service client to use a different remote copy of the WSDL - e.g. if it moves to a different host. For example, leave the systemId the same (as that's what your application code will continue to use), but change the uri to another location, e.g. "http://alternative.remote.system.host.address:6666/ServiceName.asmx?WSDL"
From what I read, this should work fine, but I haven't tried it yet!
1. create a jax-ws-catalog.xml file like the following:
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
<system systemId="http://remote.system.host.address:6666/ServiceName.asmx?WSDL"
uri="wsdl/ServiceName.wsdl"/>
</catalog>
The systemId will be the normal remote WSDL address that you would be using if you could. This is the WSDL that the web service client will be created using. The uri is the address of your local copy of the WSDL.
2. add that file to your build, directly underneath WEB-INF. This is where the JAX-WS code expects it to be. Not in the "classes" folder.
3. change your build to store the local WSDL copy inside the webapp in the "wsdl" folder. This is used by the uri attribute in the jax-ws-catalog.xml to point to your local copy of the WSDL.
4. redeploy. Now, when the web service client is created, it should not try to connect over the network to the remote WSDL, but will use the local version.
Don't forget to keep your local copy of the WSDL up to date! If you get a new version, make sure the build reflects it.
The jax-ws-catalog.xml can also be used to force your web service client to use a different remote copy of the WSDL - e.g. if it moves to a different host. For example, leave the systemId the same (as that's what your application code will continue to use), but change the uri to another location, e.g. "http://alternative.remote.system.host.address:6666/ServiceName.asmx?WSDL"
From what I read, this should work fine, but I haven't tried it yet!
Labels: JAX-WS

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
Links to this post:
Create a Link
<< Home