stevel      2002/11/19 15:28:08

  Modified:    java/src/org/apache/axis/i18n resource.properties
               java/src/org/apache/axis/handlers/soap SOAPService.java
  Log:
  now <wsdlFile> looks for a resource if the file doesnt resolve in a directory; adds 
a meaningful error message if neither is found, and closes the file afterwards.
  
  I dont think any examples use this element, so we need some new tests.
  
  Revision  Changes    Path
  1.29      +3 -1      xml-axis/java/src/org/apache/axis/i18n/resource.properties
  
  Index: resource.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/i18n/resource.properties,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- resource.properties       19 Nov 2002 19:28:28 -0000      1.28
  +++ resource.properties       19 Nov 2002 23:28:08 -0000      1.29
  @@ -1032,7 +1032,7 @@
   undefinedElem00=Element {0} is referenced but not defined.
   emptyref00=Error: missing type or ref attribute for node ''{0}''
   
  -cannotConnectError=Unable to connect
  +cannotConnectError=Unable to connectXm
   
   unabletoLoadMessages00=Unable to load messages!
   unabletoDeployTypemapping00=Unable to deploy typemapping: {0}
  @@ -1069,3 +1069,5 @@
   
   noContainerForAnonymousType=makeTypeElement() was told to create a type "{0}", with 
no containing element
   cantLoadByecode=Unable to load bytecode for class "{0}"
  +
  +wsdlFileMissing=Unable to find WSDL file or resource {0}
  
  
  
  1.88      +25 -2     xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java
  
  Index: SOAPService.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java,v
  retrieving revision 1.87
  retrieving revision 1.88
  diff -u -r1.87 -r1.88
  --- SOAPService.java  4 Nov 2002 16:32:35 -0000       1.87
  +++ SOAPService.java  19 Nov 2002 23:28:08 -0000      1.88
  @@ -80,6 +80,10 @@
   
   import javax.xml.namespace.QName;
   import java.io.FileInputStream;
  +import java.io.InputStream;
  +import java.io.FileNotFoundException;
  +import java.io.File;
  +import java.io.IOException;
   import java.util.ArrayList;
   import java.util.Enumeration;
   import java.util.Hashtable;
  @@ -364,14 +368,33 @@
               super.generateWSDL(msgContext);
               return;
           }
  +        InputStream instream = null;
   
           // Got a WSDL file in the service description, so try and read it
           try {
  -            Document doc = XMLUtils.newDocument(
  -                    new FileInputStream(serviceDescription.getWSDLFile()));
  +            String filename= serviceDescription.getWSDLFile();
  +            File file=new File(filename);
  +            if(file.exists()) {
  +                //if this resolves to a file, load it
  +                instream = new FileInputStream(filename);
  +            } else {
  +                //else load a named resource in our classloader. 
  +                instream = this.getClass().getResourceAsStream(filename);
  +                if (instream == null) {
  +                    String 
errorText=Messages.getMessage("wsdlFileMissing",filename);
  +                    throw new AxisFault(errorText);
  +                }
  +            }
  +            Document doc = XMLUtils.newDocument(instream);
               msgContext.setProperty("WSDL", doc);
           } catch (Exception e) {
               throw AxisFault.makeFault(e);
  +        } finally {
  +            if(instream!=null) {
  +                try {
  +                    instream.close();
  +                } catch (IOException e) { }
  +            }
           }
       }
       /*********************************************************************
  
  
  


Reply via email to