axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bu...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/wsdl/toJava JavaSkelWriter.java
Date Wed, 27 Feb 2002 18:42:58 GMT
butek       02/02/27 10:42:58

  Modified:    java/src/org/apache/axis/wsdl SkeletonImpl.java
               java/src/org/apache/axis/wsdl/toJava JavaSkelWriter.java
  Log:
  Added per-operation meta info to generated skeletons:
  - soapAction
  - input/output namespaces
  
  Scenario:
  - Start with WSDL from some service,
  - Generate our own service from that WSDL,
  - Generate new WSDL from our service
  - Generate new client from our WSDL.
  
  It would be very nice if the client generated from our WSDL would work
  against the original service.  Right now that doesn't work because there's
  some info (the meta info defined above) that doesn't get propagated from
  the original WSDL to ours.  This commit does the WSDL2Java work.  Rich
  will shortly do the Java2WSDL work.
  
  I really wish we wouldn't have to do this.  The two services are DIFFERENT
  services and, therefore, a client built for one shouldn't necessarily work with
  another, but I've been voted down at the SOAP Builders' interop meeting, so
  we have to make it work.
  
  Revision  Changes    Path
  1.3       +52 -6     xml-axis/java/src/org/apache/axis/wsdl/SkeletonImpl.java
  
  Index: SkeletonImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/SkeletonImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SkeletonImpl.java	19 Feb 2002 15:06:51 -0000	1.2
  +++ SkeletonImpl.java	27 Feb 2002 18:42:58 -0000	1.3
  @@ -72,13 +72,20 @@
           }
       }
   
  -    class NamesAndModes {
  +    class MetaInfo {
           String[] names;
           ParameterMode[] modes;
  +        String inputNamespace;
  +        String outputNamespace;
  +	String soapAction;
   
  -        NamesAndModes(String[] names, ParameterMode[] modes) {
  +        MetaInfo(String[] names, ParameterMode[] modes, String inputNamespace,
  +                String outputNamespace, String soapAction) {
               this.names = names;
               this.modes = modes;
  +            this.inputNamespace = inputNamespace;
  +            this.outputNamespace = outputNamespace;
  +            this.soapAction = soapAction;
           }
       }
   
  @@ -87,8 +94,10 @@
        * The first name in the array is either the return name (which
        * should be set to null if there is no return name)
        **/
  -    public void add(String operation, String[] names, ParameterMode[] modes) {
  -        table.put(operation, new NamesAndModes(names, modes));
  +    public void add(String operation, String[] names, ParameterMode[] modes,
  +            String inputNamespace, String outputNamespace, String soapAction) {
  +        table.put(operation, new MetaInfo(names, modes, inputNamespace, 
  +                outputNamespace, soapAction));
       }
   
       /**
  @@ -97,7 +106,7 @@
        * Returns null if problems occur or the parameter is not known.
        */
       public String getParameterName(String operationName, int n) {
  -        NamesAndModes value = (NamesAndModes) table.get(operationName);
  +        MetaInfo value = (MetaInfo) table.get(operationName);
           if (value == null ||
               value.names == null ||
               value.names.length <= n+1) {
  @@ -112,7 +121,7 @@
        * Returns null if problems occur or the parameter is not known.
        */
       public ParameterMode getParameterMode(String operationName, int n) {
  -        NamesAndModes value = (NamesAndModes) table.get(operationName);
  +        MetaInfo value = (MetaInfo) table.get(operationName);
           if (value == null ||
               value.modes == null ||
               value.modes.length <= n+1) {
  @@ -120,4 +129,41 @@
           }
           return value.modes[n+1];
       }
  +
  +    /**
  +     * Used to return the namespace of the input clause of the given
  +     * operation.  Returns null if problems occur.
  +     */
  +    public String getInputNamespace(String operationName) {
  +        MetaInfo value = (MetaInfo) table.get(operationName);
  +        if (value == null) {
  +            return null;
  +        }
  +        return value.inputNamespace;
  +    }
  +
  +    /**
  +     * Used to return the namespace of the output clause of the given
  +     * operation.  Returns null if problems occur.
  +     */
  +    public String getOutputNamespace(String operationName) {
  +        MetaInfo value = (MetaInfo) table.get(operationName);
  +        if (value == null) {
  +            return null;
  +        }
  +        return value.outputNamespace;
  +    }
  +
  +    /**
  +     * Used to return the SOAPAction of the given operation.
  +     * Returns null if problems occur.
  +     */
  +    public String getSOAPAction(String operationName) {
  +        MetaInfo value = (MetaInfo) table.get(operationName);
  +        if (value == null) {
  +            return null;
  +        }
  +        return value.soapAction;
  +    }
  +
   }
  
  
  
  1.15      +78 -1     xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaSkelWriter.java
  
  Index: JavaSkelWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaSkelWriter.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- JavaSkelWriter.java	27 Feb 2002 13:41:28 -0000	1.14
  +++ JavaSkelWriter.java	27 Feb 2002 18:42:58 -0000	1.15
  @@ -69,6 +69,8 @@
   import javax.wsdl.PortType;
   import javax.wsdl.QName;
   
  +import javax.wsdl.extensions.ExtensibilityElement;
  +
   import javax.wsdl.extensions.soap.SOAPBody;
   import javax.wsdl.extensions.soap.SOAPOperation;
   
  @@ -154,6 +156,21 @@
           pw.println("        return skel.getParameterMode(opName, i);");
           pw.println("    }");
           pw.println();
  +        pw.println("    public static String getInputNamespaceStatic(String opName) {");
  +        pw.println("        init();");
  +        pw.println("        return skel.getInputNamespace(opName);");
  +        pw.println("    }");
  +        pw.println();
  +        pw.println("    public static String getOutputNamespaceStatic(String opName) {");
  +        pw.println("        init();");
  +        pw.println("        return skel.getOutputNamespace(opName);");
  +        pw.println("    }");
  +        pw.println();
  +        pw.println("    public static String getSOAPAction(String opName) {");
  +        pw.println("        init();");
  +        pw.println("        return skel.getSOAPAction(opName);");
  +        pw.println("    }");
  +        pw.println();
           // Initialize operation parameter names
           pw.println("    protected static void init() {");
           pw.println("        if (skel != null) ");
  @@ -196,7 +213,67 @@
                           pw.println("                   javax.xml.rpc.ParameterMode.PARAM_MODE_OUT,");
   
                   }
  -                pw.println("                 });");                
  +                pw.println("                 },");
  +
  +                // Find the input clause's namespace
  +                BindingInput input = operation.getBindingInput();
  +                if (input == null) {
  +                    pw.println("                 null,");
  +                }
  +                else {
  +                    List elems = input.getExtensibilityElements();
  +                    boolean found = false;
  +                    Iterator it = elems.iterator();
  +                    while (!found && it.hasNext()) {
  +                        ExtensibilityElement elem = (ExtensibilityElement) it.next();
  +                        if (elem instanceof SOAPBody) {
  +                            SOAPBody body = (SOAPBody) elem;
  +                            pw.println("                 \"" + body.getNamespaceURI() +
"\",");
  +                            found = true;
  +                        }
  +                    }
  +                    if (!found) {
  +                        pw.println("                 null,");
  +                    }
  +                }
  +                
  +                // Find the output clause's namespace
  +                BindingOutput output = operation.getBindingOutput();
  +                if (output == null) {
  +                    pw.println("                 null,");
  +                }
  +                else {
  +                    List elems = output.getExtensibilityElements();
  +                    Iterator it = elems.iterator();
  +                    boolean found = false;
  +                    while (!found && it.hasNext()) {
  +                        ExtensibilityElement elem = (ExtensibilityElement) it.next();
  +                        if (elem instanceof SOAPBody) {
  +                            SOAPBody body = (SOAPBody) elem;
  +                            pw.println("                 \"" + body.getNamespaceURI() +
"\",");
  +                            found = true;
  +                        }
  +                    }
  +                    if (!found) {
  +                        pw.println("                 null,");
  +                    }
  +                }
  +                
  +                // Find the SOAPAction.
  +                List elems = operation.getExtensibilityElements();
  +                Iterator it = elems.iterator();
  +                boolean found = false;
  +                while (!found && it.hasNext()) {
  +                    ExtensibilityElement elem = (ExtensibilityElement) it.next();
  +                    if (elem instanceof SOAPOperation) {
  +                        SOAPOperation soapOp = (SOAPOperation) elem;
  +                        pw.println("                 \"" + soapOp.getSoapActionURI() +
"\");");
  +                        found = true;
  +                    }
  +                }
  +                if (!found) {
  +                    pw.println("                 null);");
  +                }
               }       
           }
           pw.println("    }");
  
  
  

Mime
View raw message