Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The best option is to use jax-ws-catalog.xml </p> <p>When you compile the local WSDL file , override the WSDL location and set it to something like</p> <pre> http://localhost/wsdl/SOAService.wsdl </pre> <p>Don't worry this is only a URI and not a URL , meaning you don't have to have the WSDL available at that address.<br> You can do this by passing the wsdllocation option to the wsdl to java compiler.</p> <p>Doing so will change your proxy code from </p> <pre><code>static { URL url = null; try { URL baseUrl; baseUrl = com.ibm.eci.soaservice.SOAService.class.getResource("."); url = new URL(baseUrl, "file:/C:/local/path/to/wsdl/SOAService.wsdl"); } catch (MalformedURLException e) { logger.warning("Failed to create URL for the wsdl Location: 'file:/C:/local/path/to/wsdl/SOAService.wsdl', retrying as a local file"); logger.warning(e.getMessage()); } SOASERVICE_WSDL_LOCATION = url; } </code></pre> <p>to </p> <pre><code>static { URL url = null; try { URL baseUrl; baseUrl = com.ibm.eci.soaservice.SOAService.class.getResource("."); url = new URL(baseUrl, "http://localhost/wsdl/SOAService.wsdl"); } catch (MalformedURLException e) { logger.warning("Failed to create URL for the wsdl Location: 'http://localhost/wsdl/SOAService.wsdl', retrying as a local file"); logger.warning(e.getMessage()); } SOASERVICE_WSDL_LOCATION = url; } </code></pre> <p>Notice file:// changed to http:// in the URL constructor. </p> <p>Now comes in jax-ws-catalog.xml. Without jax-ws-catalog.xml jax-ws will indeed try to load the WSDL from the location <pre><a href="http://localhost/wsdl/SOAService.wsdl" rel="noreferrer">http://localhost/wsdl/SOAService.wsdl</a> </pre> and fail, as no such WSDL will be available.</p> <p>But with jax-ws-catalog.xml you can redirect jax-ws to a locally packaged WSDL whenever it tries to access the WSDL @ <pre><a href="http://localhost/wsdl/SOAService.wsdl" rel="noreferrer">http://localhost/wsdl/SOAService.wsdl</a> </pre>.</p> <p>Here's jax-ws-catalog.xml </p> <pre><code>&lt;catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system"&gt; &lt;system systemId="http://localhost/wsdl/SOAService.wsdl" uri="wsdl/SOAService.wsdl"/&gt; &lt;/catalog&gt; </code></pre> <p>What you are doing is telling jax-ws that when ever it needs to load WSDL from <pre><a href="http://localhost/wsdl/SOAService.wsdl" rel="noreferrer">http://localhost/wsdl/SOAService.wsdl</a> </pre>, it should load it from local path wsdl/SOAService.wsdl.</p> <p>Now where should you put wsdl/SOAService.wsdl and jax-ws-catalog.xml ? That's the million dollar question isn't it ?<br> It should be in the META-INF directory of your application jar. </p> <p>so something like this </p> <pre> ABCD.jar |__ META-INF |__ jax-ws-catalog.xml |__ wsdl |__ SOAService.wsdl </pre> <p>This way you don't even have to override the URL in your client that access the proxy. The WSDL is picked up from within your JAR, and you avoid having to have hard-coded filesystem paths in your code.</p> <p>More info on jax-ws-catalog.xml <a href="http://jax-ws.java.net/nonav/2.1.2m1/docs/catalog-support.html" rel="noreferrer">http://jax-ws.java.net/nonav/2.1.2m1/docs/catalog-support.html</a></p> <p>Hope that helps</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload