0 Replies Latest reply on Sep 15, 2009 10:47 AM by Christian Holm

    Bad URL for jar resources in WSConsume

    Christian Holm Newbie

      Hi

      We are using WSConsume to generate stubs for a WSDL document. We put the document in the jar-file along with the generated stubs, and specify the wsdlLocation as "file.wsdl".

      The @WebServiceClient file then contains the following part in a static block:

       static {
       URL url = null;
       try {
       URL baseUrl;
       baseUrl = foo.Bar.class.getResource(".");
       url = new URL(baseUrl, "file.wsdl");
       } catch (MalformedURLException e) {
       logger.warning("Failed to create URL for the wsdl Location: 'file.wsdl', retrying as a local file");
       logger.warning(e.getMessage());
       }
       PXORDER_WSDL_LOCATION = url;
       }
      


      I don't know why it makes use of the baseURL, but this fails when the resource is in a jar file. A simpler approach (that works in a jar file also), is to simply do:

       static {
       URL url = null;
       try {
       url = foo.Bar.class.getResource("file.wsdl");
       } catch (MalformedURLException e) {
       logger.warning("Failed to create URL for the wsdl Location: 'file.wsdl', retrying as a local file");
       logger.warning(e.getMessage());
       }
       PXORDER_WSDL_LOCATION = url;
       }