title: JAX-WS client : what's the correct path to access the local WSDL?
body: <p>The problem is I need to build a web service client from a file I'm been provided. I've stored this file on the local file system and, while I keep the WSDL file in the correct file system folder, everything is fine. When I deploy it to a server or remove the WSDL from the file system folder the proxy can't find the WSDL and rises an error. I've searched the web and I've found the following posts yet I'm not been able to make it work:<br>
  <a href="https://stackoverflow.com/questions/764772/jax-ws-loading-wsdl-from-jar">JAX-WS Loading WSDL from jar</a><br>
  <a href="http://www.java.net/forum/topic/glassfish/metro-and-jaxb/client-jar-cant-find-local-wsdl-0" rel="noreferrer">http://www.java.net/forum/topic/glassfish/metro-and-jaxb/client-jar-cant-find-local-wsdl-0</a><br>
  <a href="http://blog.vinodsingh.com/2008/12/locally-packaged-wsdl.html" rel="noreferrer">http://blog.vinodsingh.com/2008/12/locally-packaged-wsdl.html</a></p>
  
  <p>I'm using NetBeans 6.1 (this is a legacy application I've to update with this new web service client). Below is the JAX-WS proxy class :</p>
  
  <pre><code>    @WebServiceClient(name = "SOAService", targetNamespace = "http://soaservice.eci.ibm.com/", wsdlLocation = "file:/C:/local/path/to/wsdl/SOAService.wsdl")
  public class SOAService
      extends Service
  {
  
      private final static URL SOASERVICE_WSDL_LOCATION;
      private final static Logger logger = Logger.getLogger(com.ibm.eci.soaservice.SOAService.class.getName());
  
      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;
      }
  
      public SOAService(URL wsdlLocation, QName serviceName) {
          super(wsdlLocation, serviceName);
      }
  
      public SOAService() {
          super(SOASERVICE_WSDL_LOCATION, new QName("http://soaservice.eci.ibm.com/", "SOAService"));
      }
  
      /**
       * @return
       *     returns SOAServiceSoap
       */
      @WebEndpoint(name = "SOAServiceSOAP")
      public SOAServiceSoap getSOAServiceSOAP() {
          return super.getPort(new QName("http://soaservice.eci.ibm.com/", "SOAServiceSOAP"), SOAServiceSoap.class);
      }
  
      /**
       * @param features
       *     A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.  Supported features not in the &lt;code&gt;features&lt;/code&gt; parameter will have their default values.
       * @return
       *     returns SOAServiceSoap
       */
      @WebEndpoint(name = "SOAServiceSOAP")
      public SOAServiceSoap getSOAServiceSOAP(WebServiceFeature... features) {
          return super.getPort(new QName("http://soaservice.eci.ibm.com/", "SOAServiceSOAP"), SOAServiceSoap.class, features);
      }
  
  }
  </code></pre>
  
  <p><br>
  This is my code to use the proxy :</p>
  
  <pre><code>   WebServiceClient annotation = SOAService.class.getAnnotation(WebServiceClient.class);
     // trying to replicate proxy settings
     URL baseUrl = com.ibm.eci.soaservice.SOAService.class.getResource("");//note : proxy uses "."
     URL url = new URL(baseUrl, "/WEB-INF/wsdl/client/SOAService.wsdl");
     //URL wsdlUrl = this.getClass().getResource("/META-INF/wsdl/SOAService.wsdl"); 
     SOAService serviceObj = new SOAService(url, new QName(annotation.targetNamespace(), annotation.name()));
     proxy = serviceObj.getSOAServiceSOAP();
     /* baseUrl;
  
     //classes\com\ibm\eci\soaservice
     //URL url = new URL(baseUrl, "../../../../wsdl/SOAService.wsdl");
  
     proxy = new SOAService().getSOAServiceSOAP();*/
     //updating service endpoint 
     Map&lt;String, Object&gt; ctxt = ((BindingProvider)proxy ).getRequestContext();
     ctxt.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192);
     ctxt.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, WebServiceUrl);
  </code></pre>
  
  <p>NetBeans put a copy of the WSDL in <em>web-inf/wsdl/client/SOAService</em>, so I don't want to add it to <em>META-INF</em> too. Service classes are in <em>WEB-INF/classes/com/ibm/eci/soaservice/</em> and baseurl variable contains the filesystem full path to it (c:\path\to\the\project...\soaservice ). The above code raises the error:</p>
  
  <blockquote>
    <p>javax.xml.ws.WebServiceException: Failed to access the WSDL at: file:/WEB-INF/wsdl/client/SOAService.wsdl. It failed with: 
            \WEB-INF\wsdl\client\SOAService.wsdl (cannot find the path)  </p>
  </blockquote>
  
  <p>So, first of all, shall I update the wsdllocation of the proxy class? Then how do I tell the SOAService class in WEB-INF/classes/com/ibm/eci/soaservice to search for the WSDL in \WEB-INF\wsdl\client\SOAService.wsdl?</p>
  
  <p><strong>EDITED</strong>: I've found this other link - <a href="http://jianmingli.com/wp/?cat=41" rel="noreferrer">http://jianmingli.com/wp/?cat=41</a>, which say to put the WSDL into the classpath. I'm ashamed to ask: how do I put it into the web application classpath?</p>