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 sc...@apache.org on 2002/05/11 00:38:50 UTC

cvs commit: xml-axis/java/src/org/apache/axis/wsdl/fromJava Emitter.java

scheu       02/05/10 15:38:50

  Modified:    java/src/org/apache/axis/wsdl/fromJava Emitter.java
  Log:
  The reworking of the Java2WSDL tool broke the --implClass option.
  This processing has been restored.
  
  If Java2WSDL is passed an interface (portType) class, the -implClass
  is used to get the parameter names.
  
  I changed the code to construct a second ServiceDesc (serviceDesc2)
  representing the --implClass, if it is specified.
  
  Prior to calling the writeMessages method, the second ServiceDesc
  is searched for a matching OperationDesc (where match means the
  same operation name and parameter java types/modes).  If found,
  the OperationDesc from the second ServiceDesc is passed to
  the writeMessages method...so that the appropriate parameters names
  are picked up.
  
  The --implClass option is extremely necessary when building
  an initial wsdl file from existing interfaces and classes.
  
  Enjoy!
  
  Revision  Changes    Path
  1.32      +60 -2     xml-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java
  
  Index: Emitter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- Emitter.java	28 Apr 2002 18:10:57 -0000	1.31
  +++ Emitter.java	10 May 2002 22:38:50 -0000	1.32
  @@ -142,6 +142,7 @@
       private String portTypeName;
   
       private ServiceDesc serviceDesc;
  +    private ServiceDesc serviceDesc2;
   
       /**
        * Construct Emitter.
  @@ -211,13 +212,31 @@
               serviceDesc.setImplClass(cls);
               //serviceDesc.setStyle();
               TypeMappingRegistry tmr = new TypeMappingRegistryImpl();
  -            serviceDesc.setTypeMapping((TypeMapping)tmr.getDefaultTypeMapping());
  +            serviceDesc.setTypeMapping((TypeMapping)
  +                                       tmr.getDefaultTypeMapping());
           }
   
           serviceDesc.setStopClasses(stopClasses);
           serviceDesc.setAllowedMethods(allowedMethods);
           serviceDesc.setDisallowedMethods(disallowedMethods);
   
  +        // If the class passed in is a portType, 
  +        // there may be an implClass that is used to 
  +        // obtain the method parameter names.  In this case,
  +        // a serviceDesc2 is built to get the method parameter names. 
  +        if (implCls != null &&
  +            implCls != cls &&
  +            serviceDesc2 == null) {
  +            serviceDesc2 = new ServiceDesc();
  +            serviceDesc2.setImplClass(implCls);
  +            TypeMappingRegistry tmr = new TypeMappingRegistryImpl();
  +            serviceDesc2.setTypeMapping((TypeMapping)
  +                                       tmr.getDefaultTypeMapping());
  +            serviceDesc2.setStopClasses(stopClasses);
  +            serviceDesc2.setAllowedMethods(allowedMethods);
  +            serviceDesc2.setDisallowedMethods(disallowedMethods);
  +        }
  +
           Document doc = null;
           Definition def = null;
           switch (mode) {
  @@ -565,7 +584,46 @@
                                                             binding,
                                                             thisOper);
               Operation oper = bindingOper.getOperation();
  -            writeMessages(def, oper, thisOper);
  +
  +            OperationDesc messageOper = thisOper;
  +            if (serviceDesc2 != null) {
  +                // If a serviceDesc contain an impl class is provided,
  +                // try and locate the corresponding operation
  +                // (same name, same parm types and modes).  If a
  +                // corresponding operation is found, it is sent
  +                // to the writeMessages method so that its parameter
  +                // names will be used in the wsdl file.
  +                OperationDesc[] operArray = 
  +                    serviceDesc2.getOperationsByName(thisOper.getName());
  +                boolean found = false;
  +                if (operArray != null) {
  +                    for (int j=0; 
  +                         j < operArray.length && !found;
  +                         j++) {
  +                        OperationDesc tryOper = operArray[j];
  +                        if (tryOper.getParameters().size() ==
  +                            thisOper.getParameters().size()) {
  +                            boolean parmsMatch = true;
  +                            for (int k=0; 
  +                                 k<thisOper.getParameters().size() && parmsMatch;
  +                                 k++) {
  +                                if (tryOper.getParameter(k).getMode() !=
  +                                    thisOper.getParameter(k).getMode() ||
  +                                    (! tryOper.getParameter(k).getJavaType().
  +                                     equals(thisOper.getParameter(k).getJavaType()))) {
  +                                    parmsMatch = false;
  +                                }
  +                                if (parmsMatch) {
  +                                    messageOper = tryOper;
  +                                    found = true;
  +                                }
  +                            }
  +                        }
  +                    }
  +                }
  +            }
  +
  +            writeMessages(def, oper, messageOper);
               portType.addOperation(oper);
           }