title: How to avoid the need to specify the WSDL location in a CXF or JAX-WS generated webservice client?
body: <p>When I generate a webservice client using wsdl2java from CXF (which generates something similar to wsimport), via maven, my services starts with codes like this:</p>
  
  <pre><code>@WebServiceClient(name = "StatusManagement", 
                    wsdlLocation = "c:/some_absolute_path_to_a_wsdl_file.wsdl",
                    targetNamespace = "http://tempuri.org/") 
  public class StatusManagement extends Service {
  
      public final static URL WSDL_LOCATION;
      public final static QName SERVICE = new QName("http://tempuri.org/", "StatusManagement");
      public final static QName WSHttpBindingIStatus = new QName("http://tempuri.org/", "WSHttpBinding_IStatus");
      static {
          URL url = null;
          try {
              url = new URL("c:/some_absolute_path_to_a_wsdl_file.wsdl");
          } catch (MalformedURLException e) {
              System.err.println("Can not initialize the default wsdl from c:/some_absolute_path_to_a_wsdl_file.wsdl");
              // e.printStackTrace();
          }
          WSDL_LOCATION = url;
      }
  </code></pre>
  
  <p>The hardcoded absolute path really sucks. The generated class won't work in any other computer other than mine.</p>
  
  <p>The first idea is to put the WSDL file (plus everything it imports, other WSDLs and XSDs) somewhere in a jar-file and classpath it. But we want to avoid this. Since all that thing was generated by CXF and JAXB based in the WSDLs and XSDs, we see no point in needing to know the WSDL at runtime.</p>
  
  <p>The wsdlLocation attribute is intended to override the WSDL location (at least this is what i readed somewhere), and it default value is "". Since we are using maven, we tried to include <code>&lt;wsdlLocation&gt;&lt;/wsdlLocation&gt;</code> inside the configuration of CXF to try to force the source generator to leave the wsdlLocation blank. However, this simply makes it ignore the XML tag because it is empty. We did a really ugly shameful hack, using <code>&lt;wsdlLocation&gt;" + "&lt;/wsdlLocation&gt;</code>.</p>
  
  <p>This changes other places too:</p>
  
  <pre><code>@WebServiceClient(name = "StatusManagement", 
                    wsdlLocation = "" + "",
                    targetNamespace = "http://tempuri.org/") 
  public class StatusManagement extends Service {
  
      public final static URL WSDL_LOCATION;
      public final static QName SERVICE = new QName("http://tempuri.org/", "StatusManagement");
      public final static QName WSHttpBindingIStatus = new QName("http://tempuri.org/", "WSHttpBinding_IStatus");
      static {
          URL url = null;
          try {
              url = new URL("" + "");
          } catch (MalformedURLException e) {
              System.err.println("Can not initialize the default wsdl from " + "");
              // e.printStackTrace();
          }
          WSDL_LOCATION = url;
      }
  </code></pre>
  
  <p>So, my questions are:</p>
  
  <ol>
  <li><p>Does we really need a WSDL location even if all the classes were generated by CXF and JAXB? If yes, why?</p></li>
  <li><p>If we do not really need the WSDL location, what is the proper and clean way to make CXF not generate it and avoiding it entirely?</p></li>
  <li><p>What bad side effects we could get with that hack? We still can't test that to see what happens, so if someone could say in advance, it would be nice.</p></li>
  </ol>