You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2001/09/01 17:23:06 UTC

cvs commit: xml-axis/java/src/org/apache/axis/utils WSDLUtils.java

gdaniels    01/09/01 08:23:05

  Modified:    java/src/org/apache/axis/handlers JWSProcessor.java
               java/src/org/apache/axis/utils WSDLUtils.java
  Log:
  Force classpath for JWS compilation to include the webapp classpath,
  which we build up manually if we find an HttpServlet in the MessageContext.
  
  A few fixes to WSDL generation code:
  
  1) remove static index for generating new namespaces
  
  2) Port name is more reasonable
  
  3) If we have a method with a MessageContext as the first arg,
      omit that from the WSDL
  
  Revision  Changes    Path
  1.17      +33 -0     xml-axis/java/src/org/apache/axis/handlers/JWSProcessor.java
  
  Index: JWSProcessor.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/JWSProcessor.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- JWSProcessor.java	2001/08/21 21:26:01	1.16
  +++ JWSProcessor.java	2001/09/01 15:23:05	1.17
  @@ -63,6 +63,7 @@
   import java.net.URLClassLoader;
   
   import org.apache.axis.* ;
  +import org.apache.axis.transport.http.HTTPConstants;
   import org.apache.axis.utils.Debug ;
   import org.apache.axis.utils.XMLUtils ;
   import org.apache.axis.utils.AxisClassLoader ;
  @@ -72,6 +73,8 @@
   
   import org.w3c.dom.* ;
   
  +import javax.servlet.http.HttpServlet;
  +
   /**
    * This handler will use the MC_REALPATH property of the MsgContext to
    * locate a *.jws (JavaWebService) file.  If found it will copy it to a
  @@ -153,6 +156,7 @@
                             "-classpath",
                             getDefaultClasspath(msgContext),
                             jFile };
  +
                   boolean           result   = compiler.compile( args );
   
                   /* Delete the temporary *.java file and check return code */
  @@ -302,6 +306,35 @@
   
               cl = cl.getParent();
           }
  +
  +        // Just to be safe (the above doesn't seem to return the webapp
  +        // classpath in all cases), manually do this:
  +
  +        HttpServlet servlet = (HttpServlet)msgContext.getProperty(
  +                                         HTTPConstants.MC_HTTP_SERVLET);
  +        if (servlet != null) {
  +            String webBase = servlet.getServletContext().
  +                                                  getRealPath("/WEB-INF");
  +            classpath.append(webBase + File.separatorChar + "classes" +
  +                             File.pathSeparatorChar);
  +            try {
  +                String libBase = webBase + File.separatorChar + "lib";
  +                File libDir = new File(libBase);
  +                String [] jarFiles = libDir.list();
  +                for (int i = 0; i < jarFiles.length; i++) {
  +                    String jarFile = jarFiles[i];
  +                    if (jarFile.endsWith(".jar")) {
  +                        classpath.append(libBase +
  +                                         File.separatorChar +
  +                                         jarFile +
  +                                         File.pathSeparatorChar);
  +                    }
  +                }
  +            } catch (Exception e) {
  +                // Oh well.  No big deal.
  +            }
  +        }
  +
   
           // boot classpath isn't found in above search
           if(System.getProperty("sun.boot.class.path") != null)
  
  
  
  1.10      +15 -5     xml-axis/java/src/org/apache/axis/utils/WSDLUtils.java
  
  Index: WSDLUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/WSDLUtils.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- WSDLUtils.java	2001/08/31 18:38:02	1.9
  +++ WSDLUtils.java	2001/09/01 15:23:05	1.10
  @@ -174,7 +174,7 @@
           Port port = def.createPort();
   
           port.setBinding(binding);
  -        port.setName("foo");
  +        port.setName(name + "Port");
   
           SOAPAddress addr = new SOAPAddress();
           addr.setLocationURI(url);
  @@ -200,8 +200,16 @@
           msg.setUndefined(false);
   
           Class[] parameters = method.getParameterTypes();
  +        int offset = 0;
           for(int i = 0, j = parameters.length; i < j; i++) {
  -            addPartToMessage(def, msg, "arg" + i, parameters[i], reg);
  +            // If the first param is a MessageContext, Axis will
  +            // generate it for us - it shouldn't be in the WSDL.
  +            if ((i == 0) && MessageContext.class.equals(parameters[i])) {
  +                offset = 1;
  +                continue;
  +            }
  +            addPartToMessage(def, msg, "arg" + (i - offset),
  +                    parameters[i], reg);
           }
   
           return msg;
  @@ -227,8 +235,6 @@
           return msg;
       }
   
  -    public static int n = 1;
  -
       public static void addPartToMessage(Definition def,
                                           Message msg,
                                           String name,
  @@ -242,7 +248,11 @@
           }
           String pref = def.getPrefix(qName.getNamespaceURI());
           if (pref == null) {
  -            def.addNamespace("ns" + n++, qName.getNamespaceURI());
  +            int i = 1;
  +            while (def.getNamespace("ns" + i) != null) {
  +                i++;
  +            }
  +            def.addNamespace("ns" + i, qName.getNamespaceURI());
           }
   
           javax.wsdl.QName typeQName =