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 Tom Jordahl <to...@macromedia.com> on 2002/10/14 18:37:48 UTC

RE: cvs commit: xml-axis/java/tools/org/apache/axis/tools/ant/wsd l Java2WsdlAntTask.java

I don't think you can have setMode() without the constants that its takes as argument...  You would still get a NoDefFound error from existing code.

I see your point about not being able to deprecate the constants, but you can note in the JavaDoc for them that people shouldn't use them.

/** DEPRECATED - Indicates style=rpc, use=encoded mode */
public static final int MODE_RPC = 0;
/** DEPRECATED - Indicates style=document, use=literal mode */
public static final int MODE_DOCUMENT = 1;
/** DEPRECATED - Indicates style=wrapped, use=literal mode */
public static final int MODE_DOC_WRAPPED = 2;

This will show up in the class documentation.

I am willing to do the work to put it back in, if that would help.

I get beat up pretty bad around here for changes we make from release to release.  I am sure you have experienced the same. :-)  I believe we have to be *very* careful with our changes to the 1.0 APIs (99% of them) so we don't keep screwing people, since a beta1 -> rc1 change is defensible but a 1.0 -> 1.1 isn't as much.

--
Tom Jordahl
Macromedia Server Development



-----Original Message-----
From: R J Scheuerle Jr [mailto:scheu@us.ibm.com]
Sent: Monday, October 14, 2002 12:24 PM
To: axis-dev@xml.apache.org
Subject: RE: cvs commit:
xml-axis/java/tools/org/apache/axis/tools/ant/wsd l
Java2WsdlAntTask.java



Normally I would agree, but most of the time the emitter is called via
command-line.  So this is a developer's api only.

I guess I could add getMode() and setMode() back in as deprecated and
indicate that the developer should use the Style/Use methods.

I don't like adding the MODE_RPC, etc. constants back in because there is
no way to deprecate them and they really aren't modes...

So what do you think of removing the MODE_ constants and deprecating the
getMode/setMode methods ?

Rich Scheuerle
IBM WebSphere & Axis Web Services Development
512-838-5115  (IBM TL 678-5115)


                                                                                                                                 
                      Tom Jordahl                                                                                                
                      <tomj@macromedia.        To:       "'axis-dev@xml.apache.org'" <ax...@xml.apache.org>                   
                      com>                     cc:                                                                               
                                               Subject:  RE: cvs commit: xml-axis/java/tools/org/apache/axis/tools/ant/wsd       
                      10/14/2002 11:07          l Java2WsdlAntTask.java                                                          
                      AM                                                                                                         
                      Please respond to                                                                                          
                      axis-dev                                                                                                   
                                                                                                                                 
                                                                                                                                 




Rich,

+1 to this change!

BUT...
Is there any way we can make this change and still be backwards compatible?

Can we keep the MODE_* in Emitter and the API that uses it (deprecated) so
folks who are calling the emitter via API don't get broken by Axis 1.1 (or
whatever)?

I think this is *very* important.  I'll bet that IBM has projects which
would appreciate this. :-)

--
Tom Jordahl
Macromedia Server Development



-----Original Message-----
From: scheu@apache.org [mailto:scheu@apache.org]
Sent: Thursday, October 10, 2002 1:23 PM
To: xml-axis-cvs@apache.org
Subject: cvs commit: xml-axis/java/tools/org/apache/axis/tools/ant/wsdl
Java2WsdlAntTask.java


scheu       2002/10/10 10:22:55

  Modified:    java/src/org/apache/axis/i18n resource.properties
               java/src/org/apache/axis/providers/java JavaProvider.java
               java/src/org/apache/axis/wsdl Java2WSDL.java
               java/src/org/apache/axis/wsdl/fromJava Emitter.java
               java/tools/org/apache/axis/tools/ant/wsdl
                        Java2WsdlAntTask.java
  Log:
  Following changes are made:
     - Added the -use option to Java2WSDL.  Valid arguments are literal and
encoded.
       The default is literal if the style is not rpc.
     - The emitter had a setMode() method to set the style.  This is
changed to setStyle.
     - Change Java2WSDL to properly use the use and style information.
Also changed
       the emitter to use the Use/Style enums instead of static constant
integers.
     - JavaProvider now invokes the java2wsdl emitter with the style/use
information
       from the serviceDesc.  Thus all the wires are now hooked up.

  Revision  Changes    Path
  1.14      +2 -0
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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- resource.properties            10 Oct 2002 15:12:15 -0000
1.13
  +++ resource.properties            10 Oct 2002 17:22:54 -0000
1.14
  @@ -1037,3 +1037,5 @@
   expectedHeaderParam=Found instance data for {0} in the soap:body instead
of the soap:header.
   noReturnParam=Didn''t find specified return QName {0}!
   noMsg=No symbol table entry found for message {0}
  +j2woptUse00=The use of items in the binding, either LITERAL or ENCODED
  +j2woptBadUse00=The value of the use option must be LITERAL or ENCODED



  1.87      +3 -11
xml-axis/java/src/org/apache/axis/providers/java/JavaProvider.java

  Index: JavaProvider.java
  ===================================================================
  RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/providers/java/JavaProvider.java,v

  retrieving revision 1.86
  retrieving revision 1.87
  diff -u -r1.86 -r1.87
  --- JavaProvider.java        9 Oct 2002 19:06:31 -0000           1.86
  +++ JavaProvider.java        10 Oct 2002 17:22:54 -0000          1.87
  @@ -373,17 +373,9 @@
               String alias = (String)service.getOption("alias");
               if(alias != null) emitter.setServiceElementName(alias);

  -            Style style = serviceDesc.getStyle();
  -
  -            // The emitter should be fixed to support all
  -            // the Style/Use flavors.
  -            if (style == Style.RPC) {
  -                emitter.setMode(Emitter.MODE_RPC);
  -            } else if (style == Style.DOCUMENT) {
  -                emitter.setMode(Emitter.MODE_DOCUMENT);
  -            } else if (style == Style.WRAPPED) {
  -                emitter.setMode(Emitter.MODE_DOC_WRAPPED);
  -            }
  +            // Set style/use
  +            emitter.setStyle(serviceDesc.getStyle());
  +            emitter.setUse(serviceDesc.getUse());

               emitter.setClsSmart(serviceDesc.getImplClass(),
locationUrl);




  1.30      +19 -8
xml-axis/java/src/org/apache/axis/wsdl/Java2WSDL.java

  Index: Java2WSDL.java
  ===================================================================
  RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/Java2WSDL.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- Java2WSDL.java           30 Sep 2002 03:36:06 -0000          1.29
  +++ Java2WSDL.java           10 Oct 2002 17:22:54 -0000          1.30
  @@ -99,6 +99,7 @@
       protected static final int TYPEMAPPING_OPT = 'T';
       protected static final int SOAPACTION_OPT = 'A';
       protected static final int STYLE_OPT = 'y';
  +    protected static final int USE_OPT = 'u';

       /**
        *  Define the understood options. Each CLOptionDescriptor contains:
  @@ -197,7 +198,11 @@
           new CLOptionDescriptor("style",
                   CLOptionDescriptor.ARGUMENT_REQUIRED,
                   STYLE_OPT,
  -                Messages.getMessage("j2woptStyle00"))
  +                Messages.getMessage("j2woptStyle00")),
  +        new CLOptionDescriptor("use",
  +                CLOptionDescriptor.ARGUMENT_REQUIRED,
  +                USE_OPT,
  +                Messages.getMessage("j2woptUse00"))

       };

  @@ -375,14 +380,20 @@

           case STYLE_OPT:
                   value = option.getArgument();
  -                if (value.equalsIgnoreCase("DOCUMENT")) {
  -                    emitter.setMode(Emitter.MODE_DOCUMENT);
  -                } else if (value.equalsIgnoreCase("RPC")) {
  -                    emitter.setMode(Emitter.MODE_RPC);
  -                } else if (value.equalsIgnoreCase("WRAPPED")) {
  -                    emitter.setMode(Emitter.MODE_DOC_WRAPPED);
  +                if (value.equalsIgnoreCase("DOCUMENT") ||
  +                    value.equalsIgnoreCase("RPC") ||
  +                    value.equalsIgnoreCase("WRAPPED")) {
  +                    emitter.setStyle(value);
  +                } else {
  +
System.out.println(Messages.getMessage("j2woptBadStyle00"));
}
  +            break;
  +        case USE_OPT:
  +                value = option.getArgument();
  +                if (value.equalsIgnoreCase("LITERAL") ||
  +                    value.equalsIgnoreCase("ENCODED")) {
  +                    emitter.setUse(value);
                   } else {
  -
System.out.println(Messages.getMessage("j2woptBadStyle00"));
  +
System.out.println(Messages.getMessage("j2woptBadUse00"));
                   }
               break;




  1.70      +76 -60
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.69
  retrieving revision 1.70
  diff -u -r1.69 -r1.70
  --- Emitter.java             10 Oct 2002 15:12:15 -0000          1.69
  +++ Emitter.java             10 Oct 2002 17:22:54 -0000          1.70
  @@ -69,6 +69,8 @@
   import org.apache.axis.description.FaultDesc;
   import org.apache.axis.encoding.DefaultTypeMappingImpl;
   import org.apache.axis.encoding.TypeMapping;
  +import org.apache.axis.enum.Style;
  +import org.apache.axis.enum.Use;
   import org.apache.axis.utils.ClassUtils;
   import org.apache.axis.utils.XMLUtils;
   import org.apache.axis.utils.JavaUtils;
  @@ -130,10 +132,7 @@
       public static final int MODE_IMPLEMENTATION = 2;

       // Style Modes
  -    public static final int MODE_RPC = 0;
  -    public static final int MODE_DOCUMENT = 1;
  -    public static final int MODE_DOC_WRAPPED = 2;
  -
  +
       private Class cls;
       private Class implCls;                 // Optional implementation
class
       private Vector allowedMethods = null;  // Names of methods to
consider
  @@ -149,7 +148,8 @@
       private String serviceElementName;
       private String targetService = null;
       private String description;
  -    private int mode = MODE_RPC;
  +    private Style  style = Style.RPC;
  +    private Use    use = null;  // Default depends on style setting
       private TypeMapping tm = null;        // Registered type mapping
       private TypeMapping defaultTM = null; // Default TM
       private Namespaces namespaces;
  @@ -396,6 +396,15 @@
        */
       private void init(int mode) {

  +        // Default use depending on setting of style
  +        if (use == null) {
  +            if (style == Style.RPC) {
  +                use = Use.ENCODED;
  +            } else {
  +                use = Use.LITERAL;
  +            }
  +        }
  +
           // Get a default TM if not specified.
           if (defaultTM == null) {
               defaultTM = DefaultTypeMappingImpl.getSingleton();
  @@ -622,8 +631,8 @@
           binding.setQName(bindingQName);

           SOAPBinding soapBinding = new SOAPBindingImpl();
  -        String modeStr = (mode == MODE_RPC) ? "rpc" : "document";
  -        soapBinding.setStyle(modeStr);
  +        String styleStr = (style == Style.RPC) ? "rpc" : "document";
  +        soapBinding.setStyle(styleStr);
           soapBinding.setTransportURI(Constants.URI_SOAP11_HTTP);

           binding.addExtensibilityElement(soapBinding);
  @@ -834,7 +843,7 @@
           }

           if (names.size() > 0) {
  -            if (mode == MODE_DOC_WRAPPED) {
  +            if (style == Style.WRAPPED) {
                   names.clear();
               }
               oper.setParameterOrdering(names);
  @@ -919,8 +928,8 @@

       private ExtensibilityElement writeSOAPBody(QName operQName) {
           SOAPBody soapBody = new SOAPBodyImpl();
  -        // for now, if its document, it is literal use.
  -        if (mode == MODE_RPC) {
  +        // for now, if its document, it is literal use.
  +        if (use == Use.ENCODED) {
               soapBody.setUse("encoded");
               soapBody.setEncodingStyles(encodingList);
           } else {
  @@ -939,7 +948,7 @@

       private SOAPFault writeSOAPFault(QName operQName, String faultName)
{
           SOAPFault soapFault = new SOAPFaultImpl();
  -        if (mode == MODE_RPC) {
  +        if (use == Use.ENCODED) {
               soapFault.setUse("encoded");
               soapFault.setEncodingStyles(encodingList);
           } else {
  @@ -1115,47 +1124,7 @@
               javaType = JavaUtils.getHolderValueType(javaType);
           }

  -        switch(mode) {
  -        case MODE_RPC: {
  -            // Add the type representing the param
  -            // For convenience, add an element for the param
  -            // Write <part name=param_name type=param_type>
  -            QName typeQName =
  -                types.writeTypeForPart(javaType,
  -                                       param.getTypeQName());
  -            types.writeElementForPart(javaType, param.getTypeQName());
  -            if (typeQName != null) {
  -                part.setName(param.getName());
  -                part.setTypeName(typeQName);
  -                msg.addPart(part);
  -            }
  -            break;
  -        }
  -        case MODE_DOCUMENT: {
  -            // Write the type representing the param.
  -            // Write the element representing the param
  -            // If an element was written
  -            //   Write <part name=param_name element=param_element>
  -            // Else its a simple type,
  -            //   Write <part name=param_name type=param_type>
  -            QName typeQName =
  -                types.writeTypeForPart(javaType,
  -                                       param.getTypeQName());
  -            QName elemQName =
  -                types.writeElementForPart(javaType,
  -                                          param.getTypeQName());
  -            if (elemQName != null) {
  -                part.setName(param.getName());
  -                part.setElementName(elemQName);
  -                msg.addPart(part);
  -            } else if (typeQName != null) {
  -                part.setName(param.getName());
  -                part.setTypeName(typeQName);
  -                msg.addPart(part);
  -            }
  -            break;
  -        }
  -        case MODE_DOC_WRAPPED: {
  +        if (style == Style.WRAPPED) {
               // Write type representing the param
               QName typeQName =
                   types.writeTypeForPart(javaType,
  @@ -1190,10 +1159,41 @@
                       msg.addPart(part);
                   }
               }
  -            break;
  -        }
  -        default:
  -            // ?? Throw an exception here?
  +        } else if (use == Use.ENCODED) {
  +            // Add the type representing the param
  +            // For convenience, add an element for the param
  +            // Write <part name=param_name type=param_type>
  +            QName typeQName =
  +                types.writeTypeForPart(javaType,
  +                                       param.getTypeQName());
  +            types.writeElementForPart(javaType, param.getTypeQName());
  +            if (typeQName != null) {
  +                part.setName(param.getName());
  +                part.setTypeName(typeQName);
  +                msg.addPart(part);
  +            }
  +        } else if (use == Use.LITERAL) {
  +            // Write the type representing the param.
  +            // Write the element representing the param
  +            // If an element was written
  +            //   Write <part name=param_name element=param_element>
  +            // Else its a simple type,
  +            //   Write <part name=param_name type=param_type>
  +            QName typeQName =
  +                types.writeTypeForPart(javaType,
  +                                       param.getTypeQName());
  +            QName elemQName =
  +                types.writeElementForPart(javaType,
  +                                          param.getTypeQName());
  +            if (elemQName != null) {
  +                part.setName(param.getName());
  +                part.setElementName(elemQName);
  +                msg.addPart(part);
  +            } else if (typeQName != null) {
  +                part.setName(param.getName());
  +                part.setTypeName(typeQName);
  +                msg.addPart(part);
  +            }
           }
           return param.getName();
       }
  @@ -1698,12 +1698,28 @@
           this.defaultTM = defaultTM;
       }

  -    public int getMode() {
  -        return mode;
  +    public Style getStyle() {
  +        return style;
  +    }
  +
  +    public void setStyle(String value) {
  +        style = Style.getStyle(value);
  +    }
  +
  +    public void setStyle(Style value) {
  +        style = value;
  +    }
  +
  +    public Use getUse() {
  +        return use;
  +    }
  +
  +    public void setUse(String value) {
  +        use = Use.getUse(value);
       }

  -    public void setMode(int mode) {
  -        this.mode = mode;
  +    public void setUse(Use value) {
  +        use = value;
       }

       public ServiceDesc getServiceDesc() {



  1.5       +8 -7
xml-axis/java/tools/org/apache/axis/tools/ant/wsdl/Java2WsdlAntTask.java

  Index: Java2WsdlAntTask.java
  ===================================================================
  RCS file:
/home/cvs/xml-axis/java/tools/org/apache/axis/tools/ant/wsdl/Java2WsdlAntTask.java,v

  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Java2WsdlAntTask.java          26 Sep 2002 20:59:58 -0000
1.4
  +++ Java2WsdlAntTask.java          10 Oct 2002 17:22:55 -0000
1.5
  @@ -91,6 +91,7 @@
       private String stopClasses = null;
       private String tm = "1.1";
       private String style = null;
  +    private String use = null;

       // The method executing the task
       public void execute() throws BuildException {
  @@ -111,6 +112,7 @@
               log("\tstopClasses:" + stopClasses, Project.MSG_VERBOSE);
               log("\ttypeMappingVersion:" + tm, Project.MSG_VERBOSE);
               log("\tstyle:" + style, Project.MSG_VERBOSE);
  +            log("\tuse:" + use, Project.MSG_VERBOSE);
               log("\toutputImpl:" + outputImpl, Project.MSG_VERBOSE);
               log("\tnamespaceImpl:" + namespaceImpl,
Project.MSG_VERBOSE);
               log("\tlocationImport:" + locationImport,
Project.MSG_VERBOSE);
  @@ -148,14 +150,13 @@

emitter.setDefaultTypeMapping(DefaultSOAP12TypeMappingImpl.create());
               }
               if (style != null) {
  -                if (style.equalsIgnoreCase("DOCUMENT")) {
  -                    emitter.setMode(Emitter.MODE_DOCUMENT);
  -                } else if (style.equalsIgnoreCase("RPC")) {
  -                    emitter.setMode(Emitter.MODE_RPC);
  -                } else if (style.equalsIgnoreCase("WRAPPED")) {
  -                    emitter.setMode(Emitter.MODE_DOC_WRAPPED);
  -                }
  +                emitter.setStyle(style);
               }
  +
  +            if (use != null) {
  +                emitter.setUse(use);
  +            }
  +
               if (input != null) {
                   emitter.setInputWSDL(input);
               }