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 bu...@us.ibm.com on 2002/08/02 15:34:36 UTC

Changing WDSDL2Java symbol table slightly (was: Re: cvs commit: xml-axis/java/test/wsdl/attachments mime.wsdl)

This note is particularly for dims, but anyone who uses the symbol table
from WSDL2Java might be affected.  There are a couple notes from my recent
commit like:

+        if (parms.returnType != null) {
+            // Construct a Parameter for the return.
+            // RJB NOTE:  The return info should really just be a
Parameter
+            //            rather than duplicating the same info on the
+            //            Parameters object.
+            Parameter returnParm = new Parameter();
+            returnParm.setMIMEType(parms.returnMIMEType);
+            returnParm.setType(parms.returnType);
+            ret = Utils.getParameterTypeName(returnParm);
+        }

Unless someone objects to my changing things on them, I want to change org.
apache.axis.wsdl.symbolTable.Parameters.  I'll remove:

    public TypeEntry returnType = null;
    public QName returnName = null;
    public String returnMIMEType = null;

and replace it with:

    public Parameter returnParam = null;

And fix the rest of the code accordingly.

Any objections?

Russell Butek
butek@us.ibm.com


butek@apache.org on 08/02/2002 07:55:34 AM

Please respond to axis-dev@xml.apache.org

To:    xml-axis-cvs@apache.org
cc:
Subject:    cvs commit: xml-axis/java/test/wsdl/attachments mime.wsdl



butek       2002/08/02 05:55:34

  Modified:    java/src/org/apache/axis/description ParameterDesc.java
                        ServiceDesc.java
               java/src/org/apache/axis/providers/java RPCProvider.java
               java/src/org/apache/axis/utils JavaUtils.java
               java/src/org/apache/axis/wsdl/symbolTable BindingEntry.java
                        SymbolTable.java
               java/src/org/apache/axis/wsdl/toJava
                        JavaGeneratorFactory.java JavaSkelWriter.java
                        JavaStubWriter.java JavaTestCaseWriter.java
                        Utils.java
               java/test/wsdl/attachments mime.wsdl
  Log:
  One more small step toward full attachment support.  WSDL2Java now
  supports javax.mail.internet.MimeMultipart.

  Revision  Changes    Path
  1.16      +5 -2      xml-
  axis/java/src/org/apache/axis/description/ParameterDesc.java

  Index: ParameterDesc.java
  ===================================================================
  RCS file: /home/cvs/xml-
  axis/java/src/org/apache/axis/description/ParameterDesc.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ParameterDesc.java      26 Jul 2002 14:57:48 -0000    1.15
  +++ ParameterDesc.java      2 Aug 2002 12:55:33 -0000     1.16
  @@ -140,8 +140,11 @@
                                            "INOUT" : "OUT:  "
                                            + "position:" + order) + "\n";
           text+=indent + "isReturn:   " + isReturn + "\n";
  -        text+=indent + "typeQName:  " + typeQName+ "\n";
  -        text+=indent + "javaType:   " + javaType+ "\n";
  +        text+=indent + "typeQName:  " + typeQName + "\n";
  +        text+=indent + "javaType:   " + javaType + "\n";
  +        if (mimeType != null) {
  +            text+=indent + "MIMEType:   " + mimeType + "\n";
  +        }
           return text;
       } // toString




  1.44      +11 -1     xml-
  axis/java/src/org/apache/axis/description/ServiceDesc.java

  Index: ServiceDesc.java
  ===================================================================
  RCS file: /home/cvs/xml-
  axis/java/src/org/apache/axis/description/ServiceDesc.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- ServiceDesc.java  29 Jul 2002 19:20:50 -0000    1.43
  +++ ServiceDesc.java  2 Aug 2002 12:55:33 -0000     1.44
  @@ -586,7 +586,9 @@
                           // This is a match if the paramClass is somehow
                           // convertable to the "real" parameter type.  If
                           not,
                           // break out of this loop.
  -                        if (!JavaUtils.isConvertable(paramClass,
  heldType)) {
  +                        if (!JavaUtils.isConvertable(paramClass,
  heldType) &&
  +                                !isMimeConvertable(
  +                                param.getMIMEType(), heldType)) {
                               break;
                           }
                       }
  @@ -623,6 +625,14 @@
               syncOperationToClass(oper, superClass);
           }
       }
  +
  +    /**
  +     * Is this is a MIME type and is it convertible to the given type?
  +     */
  +    private boolean isMimeConvertable(String mimeType, Class cls) {
  +        return mimeType != null &&
  +                cls.getName().equals(JavaUtils.mimeToJava(mimeType));
  +    } // isMimeConvertable

       /**
        * Fill in a service description by introspecting the implementation



  1.81      +10 -0     xml-
  axis/java/src/org/apache/axis/providers/java/RPCProvider.java

  Index: RPCProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-
  axis/java/src/org/apache/axis/providers/java/RPCProvider.java,v
  retrieving revision 1.80
  retrieving revision 1.81
  diff -u -r1.80 -r1.81
  --- RPCProvider.java  26 Jul 2002 14:57:48 -0000    1.80
  +++ RPCProvider.java  2 Aug 2002 12:55:33 -0000     1.81
  @@ -59,6 +59,7 @@
   import org.apache.axis.Constants;
   import org.apache.axis.MessageContext;
   import org.apache.axis.attachments.AttachmentPart;
  +import org.apache.axis.attachments.MimeMultipartDataSource;
   import org.apache.axis.attachments.PlainTextDataSource;
   import org.apache.axis.enum.Style;
   import org.apache.axis.description.OperationDesc;
  @@ -77,6 +78,7 @@
   import org.apache.commons.logging.Log;

   import javax.activation.DataHandler;
  +import javax.mail.internet.MimeMultipart;
   import javax.xml.namespace.QName;
   import javax.xml.rpc.holders.Holder;
   import java.lang.reflect.Method;
  @@ -331,6 +333,10 @@
                       objRes = new DataHandler(new PlainTextDataSource(
                               "ret", (String) objRes));
                   }
  +                else if (mimeType.startsWith("multipart/")) {
  +                    objRes = new DataHandler(new
  MimeMultipartDataSource(
  +                            "ret", (MimeMultipart) objRes));
  +                }
               }
               RPCParam param = new RPCParam(returnQName, objRes);
               param.setParamDesc(operation.getReturnParamDesc());
  @@ -351,6 +357,10 @@
                       if (mimeType.equals("text/plain")) {
                           value = new DataHandler(
                                   new PlainTextDataSource("out", (String)
                                   value));
  +                    }
  +                    else if (mimeType.startsWith("multipart/")) {
  +                        value = new DataHandler(new
  MimeMultipartDataSource(
  +                                "out", (MimeMultipart) value));
                       }
                   }
                   param.setValue(value);



  1.62      +29 -3     xml-axis/java/src/org/apache/axis/utils/JavaUtils.
  java

  Index: JavaUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/JavaUtils.
  java,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- JavaUtils.java    24 Jul 2002 16:15:03 -0000    1.61
  +++ JavaUtils.java    2 Aug 2002 12:55:33 -0000     1.62
  @@ -83,6 +83,8 @@
   import java.util.List;
   import java.beans.Introspector;

  +import javax.mail.internet.MimeMultipart;
  +
   import javax.xml.soap.SOAPException;

   /** Utility class to deal with Java language related issues, such
  @@ -240,9 +242,12 @@
           }

           // Convert an AttachmentPart to the given destination class.
  -        if (arg instanceof AttachmentPart && destClass == String.class)
  {
  +        if (arg instanceof AttachmentPart) {
               try {
  -                return ((AttachmentPart)arg).getDataHandler().
  getContent();
  +                if (destClass == String.class
  +                        || destClass == MimeMultipart.class) {
  +                    return ((AttachmentPart)arg).getDataHandler().
  getContent();
  +                }
               }
               catch (IOException ioe) {
               }
  @@ -894,7 +899,7 @@
       public static class HolderException extends Exception
       {
           public HolderException(String msg) { super(msg); }
  -    };
  +    }


       /**
  @@ -1062,4 +1067,25 @@
           return isFalse(value, true);
       }

  +    /**
  +     * Given the MIME type string, return the Java mapping.
  +     */
  +    public static String mimeToJava(String mime) {
  +        if ("image/gif".equals(mime) || "image/jpeg".equals(mime)) {
  +            return "java.awt.Image";
  +        }
  +        else if ("text/plain".equals(mime)) {
  +            return "java.lang.String";
  +        }
  +        else if ("text/xml".equals(mime) || "application/xml".
  equals(mime)) {
  +            return "javax.xml.transform.Source";
  +        }
  +        else if (mime != null && mime.startsWith("multipart/")) {
  +            return "javax.mail.internet.MimeMultipart";
  +        }
  +        else {
  +            return null;
  +        }
  +    } // mimeToJava
  +
   }



  1.3       +18 -4     xml-
  axis/java/src/org/apache/axis/wsdl/symbolTable/BindingEntry.java

  Index: BindingEntry.java
  ===================================================================
  RCS file: /home/cvs/xml-
  axis/java/src/org/apache/axis/wsdl/symbolTable/BindingEntry.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BindingEntry.java 24 Jul 2002 16:15:03 -0000    1.2
  +++ BindingEntry.java 2 Aug 2002 12:55:33 -0000     1.3
  @@ -87,6 +87,9 @@
       private boolean hasLiteral;
       private HashMap attributes;
       private HashMap parameters = new HashMap();
  +
  +    // This is a map of a map.  It's a map keyed on operation name whose
  values
  +    // are maps keyed on parameter name.
       private Map     mimeTypes;


  @@ -136,8 +139,14 @@
        * Get the mime mapping for the given parameter name.
        * If there is none, this returns null.
        */
  -    public String getMIMEType(String parameterName) {
  -        return (String) mimeTypes.get(parameterName);
  +    public String getMIMEType(String operationName, String
  parameterName) {
  +        Map opMap = (Map) mimeTypes.get(operationName);
  +        if (opMap == null) {
  +            return null;
  +        }
  +        else {
  +            return (String) opMap.get(parameterName);
  +        }
       } // getMIMEType

       /**
  @@ -150,8 +159,13 @@
       /**
        * Set the mime mapping for the given parameter name.
        */
  -    public void setMIMEType(String parameterName, String type) {
  -        mimeTypes.put(parameterName, type);
  +    public void setMIMEType(String operationName, String parameterName,
  String type) {
  +        Map opMap = (Map) mimeTypes.get(operationName);
  +        if (opMap == null) {
  +            opMap = new HashMap();
  +            mimeTypes.put(operationName, opMap);
  +        }
  +        opMap.put(parameterName, type);
       } // setMIMEType

       /**



  1.18      +7 -5      xml-
  axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java

  Index: SymbolTable.java
  ===================================================================
  RCS file: /home/cvs/xml-
  axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- SymbolTable.java  29 Jul 2002 21:30:00 -0000    1.17
  +++ SymbolTable.java  2 Aug 2002 12:55:33 -0000     1.18
  @@ -1231,7 +1231,7 @@
                   // We're either RPC or literal + not wrapped.

                   param.setName(partName);
  -                param.setMIMEType(bindingEntry == null ? null :
  bindingEntry.getMIMEType(partName));
  +                param.setMIMEType(bindingEntry == null ? null :
  bindingEntry.getMIMEType(opName, partName));

                   // Add this type or element name
                   if (typeName != null) {
  @@ -1326,7 +1326,7 @@
                       ElementDecl elem = (ElementDecl) vTypes.
                       elementAt(j);
                       Parameter p = new Parameter();
                       p.setQName(elem.getName());
  -                    p.setMIMEType(bindingEntry == null ? null :
  bindingEntry.getMIMEType(partName));
  +                    p.setMIMEType(bindingEntry == null ? null :
  bindingEntry.getMIMEType(opName, partName));
                       p.setType(elem.getType());
                       v.add(p);
                   }
  @@ -1335,7 +1335,7 @@
                   // we can't use wrapped mode.
                   Parameter p = new Parameter();
                   p.setName(partName);
  -                p.setMIMEType(bindingEntry == null ? null :
  bindingEntry.getMIMEType(partName));
  +                p.setMIMEType(bindingEntry == null ? null :
  bindingEntry.getMIMEType(opName, partName));

                   if (typeName != null) {
                       p.setType(getType(typeName));
  @@ -1389,6 +1389,8 @@
                   int inputBodyType = BindingEntry.USE_ENCODED;
                   int outputBodyType = BindingEntry.USE_ENCODED;
                   BindingOperation bindOp = (BindingOperation) opIterator.
                   next();
  +                Map opMimeTypes = new HashMap();
  +                mimeTypes.put(bindOp.getName(), opMimeTypes);

                   // input
                   if (bindOp.getBindingInput() != null) {
  @@ -1409,7 +1411,7 @@
                               }
                               else if (obj instanceof
                               MIMEMultipartRelated) {
                                   IntHolder holder = new
  IntHolder(inputBodyType);
  -                                mimeTypes.putAll(collectMIMETypes(
  +                                opMimeTypes.putAll(collectMIMETypes(
                                           (MIMEMultipartRelated) obj,
                                   holder, bindOp));
                                   inputBodyType = holder.value;
                               }
  @@ -1436,7 +1438,7 @@
                               }
                               else if (obj instanceof
                               MIMEMultipartRelated) {
                                   IntHolder holder = new
  IntHolder(outputBodyType);
  -                                mimeTypes.putAll(collectMIMETypes(
  +                                opMimeTypes.putAll(collectMIMETypes(
                                           (MIMEMultipartRelated) obj,
                                   holder, bindOp));
                                   outputBodyType = holder.value;
                               }



  1.16      +12 -2     xml-
  axis/java/src/org/apache/axis/wsdl/toJava/JavaGeneratorFactory.java

  Index: JavaGeneratorFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-
  axis/java/src/org/apache/axis/wsdl/toJava/JavaGeneratorFactory.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- JavaGeneratorFactory.java     24 Jul 2002 16:15:04 -0000    1.15
  +++ JavaGeneratorFactory.java     2 Aug 2002 12:55:33 -0000     1.16
  @@ -839,9 +839,19 @@
        * Construct the signature, which is used by both the interface and
        the stub.
        */
       private String constructSignature(Parameters parms, String opName) {
  -        String name  = Utils.xmlNameToJava(opName);
  +        String name = Utils.xmlNameToJava(opName);

  -        String ret = parms.returnType == null ? "void" : parms.
  returnType.getName();
  +        String ret = "void";
  +        if (parms.returnType != null) {
  +            // Construct a Parameter for the return.
  +            // RJB NOTE:  The return info should really just be a
  Parameter
  +            //            rather than duplicating the same info on the
  +            //            Parameters object.
  +            Parameter returnParm = new Parameter();
  +            returnParm.setMIMEType(parms.returnMIMEType);
  +            returnParm.setType(parms.returnType);
  +            ret = Utils.getParameterTypeName(returnParm);
  +        }
           String signature = "    public " + ret + " " + name + "(";

           boolean needComma = false;



  1.40      +11 -5     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.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- JavaSkelWriter.java     26 Jul 2002 14:57:48 -0000    1.39
  +++ JavaSkelWriter.java     2 Aug 2002 12:55:33 -0000     1.40
  @@ -190,10 +190,9 @@
                       pw.println("            " +
                           "new org.apache.axis.description.ParameterDesc("
                           +
                           Utils.getNewQName(paramName) +
  -                        ", " + modeStr + ", " +
  -                        Utils.getNewQName(paramType) +
  -                        ", " +
  -                        p.getType().getName() + ".class" +
  +                        ", " + modeStr +
  +                        ", " + Utils.getNewQName(paramType) +
  +                        ", " + Utils.getParameterTypeName(p) + ".class"
  +
                           ", " + mimeType + "), ");
                   }

  @@ -354,7 +353,14 @@
           if (parms.returnType == null) {
               pw.print("        ");
           } else {
  -            pw.print("        " + parms.returnType.getName() + " ret =
  ");
  +            // Construct a Parameter for the return.
  +            // RJB NOTE:  The return info should really just be a
  +            //            Parameter rather than duplicating the same
  +            //            info on the Parameters object.
  +            Parameter returnParm = new Parameter();
  +            returnParm.setMIMEType(parms.returnMIMEType);
  +            returnParm.setType(parms.returnType);
  +            pw.print("        " + Utils.getParameterTypeName(returnParm)
  + " ret = ");
           }
           String call = "impl." + Utils.xmlNameToJava(operation.getName())
           + "(";
           boolean needComma = false;



  1.79      +51 -20    xml-
  axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java

  Index: JavaStubWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-
  axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java,v
  retrieving revision 1.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- JavaStubWriter.java     24 Jul 2002 16:15:04 -0000    1.78
  +++ JavaStubWriter.java     2 Aug 2002 12:55:33 -0000     1.79
  @@ -622,12 +622,19 @@
                   if (mode == Parameter.INOUT) {
                       javifiedName += ".value";
                   }
  -
  +
                   if (mimeType.equals("text/plain")) {
  -                    pw.println("        javax.activation.DataHandler
  _dh" + numberOfInMIMES++ +
  +                    pw.println("        javax.activation.DataHandler
  _dh" +
  +                            numberOfInMIMES++ +
                               " = new javax.activation.DataHandler(new
                               org.apache.axis.attachments.
                               PlainTextDataSource(\"" +
                               javifiedName + "\", " + javifiedName +
                               "));");
                   }
  +                else if (mimeType.startsWith("multipart/")) {
  +                    pw.println("        javax.activation.DataHandler
  _dh" +
  +                            numberOfInMIMES++ +
  +                            " = new javax.activation.DataHandler(new
  org.apache.axis.attachments.MimeMultipartDataSource(\"" +
  +                            javifiedName + "\", " + javifiedName +
  "));");
  +                }
               }
           }
           numberOfInMIMES = 0;
  @@ -656,6 +663,10 @@
                           pw.print("_dh" + numberOfInMIMES++);
                           continue;
                       }
  +                    else if (mimeType.startsWith("multipart/")) {
  +                        pw.print("_dh" + numberOfInMIMES++);
  +                        continue;
  +                    }
                   }

                   // If we get here, then we didn't find a MIME type
  @@ -740,9 +751,12 @@
                                      TypeEntry type, String mimeType,
                                      String source) {
           String realTarget = null;
  -        if (mimeType != null && mimeType.equals("text/plain")) {
  +        if (mimeType != null) {
               realTarget = target;
  -            target = "javax.activation.DataHandler _returnDH = ";
  +            if(mimeType.equals("text/plain")
  +                    || mimeType.startsWith("multipart/")) {
  +                target = "javax.activation.DataHandler _returnDH = ";
  +            }
           }
           if (type != null && type.getName() != null) {
               // Try casting the output to the expected output.
  @@ -752,30 +766,47 @@
                          Utils.getResponseString(type, mimeType, source));

               if (mimeType != null) {
  -                if (mimeType.equals("text/plain")) {
  -                    pw.println("                java.io.InputStream
  _DHIS = _returnDH.getInputStream();");
  -                    pw.println("                byte[] _DHISBytes = new
  byte[_DHIS.available()];");
  -                    pw.println("                _DHIS.
  read(_DHISBytes);");
  -                    pw.println("                " + realTarget +
  -                            Utils.getResponseString(type, null, "new
  String(_DHISBytes)"));
  -                }
  -                else {
  -                    pw.println("                " + realTarget +
  -                            Utils.getResponseString(type, mimeType,
  source));
  -                }
  +                writeMIMETypeReturn(pw, realTarget, source, type,
  mimeType);
                   target = realTarget;
               }

               pw.println("            } catch (java.lang.Exception
  _exception) {");
  -            pw.println("                " + target +
  -                       Utils.getResponseString(type, null,
  -                                         "org.apache.axis.utils.
  JavaUtils.convert(" +
  -                                         source + ", " +
  -                                         type.getName() + ".class)"));
  +            if (mimeType != null) {
  +                pw.println("                // Is there anything we can
  do for MIME types?");
  +                pw.println("                " + target + "null;");
  +            }
  +            else {
  +                pw.println("                " + target +
  +                        Utils.getResponseString(type, null,
  +                        "org.apache.axis.utils.JavaUtils.convert(" +
  +                        source + ", " + type.getName() + ".class)"));
  +            }
               pw.println("            }");
           } else {
               pw.println("              " + target +
                          Utils.getResponseString(type, mimeType, source));
           }
       }
  +
  +    /**
  +     * Write the statements that convert the returned DataHandler to the
  appropriate
  +     * MIME mapping type.
  +     */
  +    private void writeMIMETypeReturn(PrintWriter pw, String target,
  +            String source, TypeEntry type, String mimeType) {
  +        if (mimeType.equals("text/plain")) {
  +            pw.println("                java.io.InputStream _DHIS =
  _returnDH.getInputStream();");
  +            pw.println("                byte[] _DHISBytes = new
  byte[_DHIS.available()];");
  +            pw.println("                _DHIS.read(_DHISBytes);");
  +            pw.println("                " + target + "new
  String(_DHISBytes);");
  +        }
  +        else if (mimeType.startsWith("multipart/")) {
  +            pw.println("                " + target +
  +                    "new javax.mail.internet.MimeMultipart(_returnDH.
  getDataSource());");
  +        }
  +        else {
  +            pw.println("                " + target +
  +                       Utils.getResponseString(type, mimeType, source));
  +        }
  +    } // writeMIMETypeReturn
   } // class JavaStubWriter



  1.33      +20 -3     xml-
  axis/java/src/org/apache/axis/wsdl/toJava/JavaTestCaseWriter.java

  Index: JavaTestCaseWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-
  axis/java/src/org/apache/axis/wsdl/toJava/JavaTestCaseWriter.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- JavaTestCaseWriter.java 24 Jul 2002 16:15:04 -0000    1.32
  +++ JavaTestCaseWriter.java 2 Aug 2002 12:55:34 -0000     1.33
  @@ -185,10 +185,18 @@
               pw.println("        try {");
               if (params.returnType != null) {
                   pw.print("            ");
  -                pw.print(params.returnType.getName());
  +                // Construct a Parameter for the return.
  +                // RJB NOTE:  The return info should really just be a
  +                //            Parameter rather than duplicating the same
  +                //            info on the Parameters object.
  +                Parameter returnParm = new Parameter();
  +                returnParm.setMIMEType(params.returnMIMEType);
  +                returnParm.setType(params.returnType);
  +                pw.print(Utils.getParameterTypeName(returnParm));
                   pw.print(" value = ");

  -                if ( Utils.isPrimitiveType( params.returnType ) ) {
  +                if (params.returnMIMEType == null &&
  +                        Utils.isPrimitiveType(params.returnType)) {
                       if ( "boolean".equals( params.returnType.getName() )
                           ) {
                           pw.println("false;");
                       } else {
  @@ -221,10 +229,11 @@

                   Parameter param = (Parameter) iparam.next();
                   String paramType = param.getType().getName();
  +                String mimeType = param.getMIMEType();
                   String suffix = "";

                   if (param.getMode() != Parameter.IN) {
  -                    pw.print("new " + Utils.holder(param.getMIMEType(),
  param.getType(), emitter)
  +                    pw.print("new " + Utils.holder(mimeType, param.
  getType(), emitter)
                               + "(");
                       suffix = ")";
                   }
  @@ -239,6 +248,14 @@
                               pw.print("(short)0");
                           } else {
                               pw.print("0");
  +                        }
  +                    } else if (mimeType != null) {
  +                        if (mimeType.equals("image/gif") ||
  +                                mimeType.equals("image/jpeg")) {
  +                            pw.print("java.awt.Toolkit.
  getDefaultToolkit().getImage(new byte[0])");
  +                        }
  +                        else {
  +                            pw.print("new " + Utils.
  getParameterTypeName(param) + "()");
                           }
                       } else if (paramType.equals("java.lang.Boolean")) {
                           pw.print("new java.lang.Boolean(false)");



  1.44      +1 -22     xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.
  java

  Index: Utils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.
  java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- Utils.java  31 Jul 2002 20:47:01 -0000    1.43
  +++ Utils.java  2 Aug 2002 12:55:34 -0000     1.44
  @@ -597,34 +597,13 @@
               ret = parm.getType().getName();
           }
           else {
  -            ret = mimeToJava(mime);
  +            ret = JavaUtils.mimeToJava(mime);
               if (ret == null) {
                   ret = parm.getType().getName();
               }
           }
           return ret;
       } // getParameterTypeName
  -
  -    /**
  -     * Given the MIME type string, return the Java mapping.
  -     */
  -    private static String mimeToJava(String mime) {
  -        if ("image/gif".equals(mime) || "image/jpeg".equals(mime)) {
  -            return "java.awt.Image";
  -        }
  -        else if ("text/plain".equals(mime)) {
  -            return "java.lang.String";
  -        }
  -        else if ("text/xml".equals(mime) || "application/xml".
  equals(mime)) {
  -            return "javax.xml.transform.Source";
  -        }
  -        else if (mime != null && mime.startsWith("multipart/")) {
  -            return "javax.mail.internet.MimeMultipart";
  -        }
  -        else {
  -            return null;
  -        }
  -    } // mimeToJava

       /**
        * Get the QName that could be used in the xsi:type



  1.3       +72 -58    xml-axis/java/test/wsdl/attachments/mime.wsdl

  Index: mime.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/attachments/mime.wsdl,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- mime.wsdl   26 Jul 2002 14:57:48 -0000    1.2
  +++ mime.wsdl   2 Aug 2002 12:55:34 -0000     1.3
  @@ -29,18 +29,27 @@
       </schema>
     </types>

  -  <message name="m0"/>
  -  <message name="m1">
  +  <message name="empty"/>
  +  <message name="pt1">
       <part name="body" element="tns:GetCompanyInfo"/>
     </message>
  -  <message name="m2">
  +  <message name="pt2">
       <part name="body" element="tns:GetCompanyInfo2"/>
       <part name="docs" type="xsd:string"/>
       <part name="logo" type="xsd:hexBinary"/>
     </message>
  -  <message name="m3">
  +  <message name="pt3">
       <part name="body" type="xsd:string"/>
     </message>
  +  <message name="pt4">
  +    <part name="out" type="xsd:string"/>
  +  </message>
  +  <message name="mmp3">
  +    <part name="body" type="xsd:string"/>
  +  </message>
  +  <message name="mmp4">
  +    <part name="out" type="xsd:string"/>
  +  </message>

     <portType name="pt1">
   <!--
  @@ -54,19 +63,37 @@
       </operation>
   -->
       <operation name="inputPlainText">
  -      <input message="tns:m3"/>
  -      <output message="tns:m0"/>
  +      <input message="tns:pt3"/>
  +      <output message="tns:empty"/>
  +    </operation>
  +    <operation name="inoutPlainText">
  +      <input message="tns:pt3"/>
  +      <output message="tns:pt3"/>
       </operation>
       <operation name="echoPlainText">
  -      <input message="tns:m3"/>
  -      <output message="tns:m3"/>
  +      <input message="tns:pt3"/>
  +      <output message="tns:pt4"/>
       </operation>
  -<!-- This operation fails for the document binding.  I'll figure it out
  later...
       <operation name="outputPlainText">
  -      <input message="tns:m0"/>
  -      <output message="tns:m3"/>
  +      <input message="tns:empty"/>
  +      <output message="tns:pt3"/>
  +    </operation>
  +    <operation name="inputMimeMultipart">
  +      <input message="tns:mmp3"/>
  +      <output message="tns:empty"/>
  +    </operation>
  +    <operation name="inoutMimeMultipart">
  +      <input message="tns:mmp3"/>
  +      <output message="tns:mmp3"/>
  +    </operation>
  +    <operation name="echoMimeMultipart">
  +      <input message="tns:mmp3"/>
  +      <output message="tns:mmp4"/>
  +    </operation>
  +    <operation name="outputMimeMultipart">
  +      <input message="tns:empty"/>
  +      <output message="tns:mmp3"/>
       </operation>
  --->
     </portType>

     <binding name="b1" type="tns:pt1">
  @@ -127,7 +154,7 @@
           <soap:body use="encoded"/>
         </output>
       </operation>
  -    <operation name="echoPlainText">
  +    <operation name="inoutPlainText">
         <soap:operation soapAction=""/>
         <input>
          <mime:multipartRelated>
  @@ -144,122 +171,109 @@
           </mime:multipartRelated>
         </output>
       </operation>
  -<!--
  -    <operation name="outputPlainText">
  +    <operation name="echoPlainText">
         <soap:operation soapAction=""/>
         <input>
  -        <soap:body use="encoded"/>
  +       <mime:multipartRelated>
  +          <mime:part>
  +            <mime:content part="body" type="text/plain"/>
  +          </mime:part>
  +        </mime:multipartRelated>
         </input>
         <output>
          <mime:multipartRelated>
             <mime:part>
  -            <mime:content part="body" type="text/plain"/>
  +            <mime:content part="out" type="text/plain"/>
             </mime:part>
           </mime:multipartRelated>
         </output>
       </operation>
  --->
  -  </binding>
  -
  -  <binding name="b2" type="tns:pt1">
  -    <soap:binding style="document"
  -                  transport="http://schemas.xmlsoap.org/soap/http"/>
  -<!--
  -    <operation name="GetCompanyInfo">
  -      <soap:operation soapAction="http://example.com/GetCompanyInfo"/>
  +    <operation name="outputPlainText">
  +      <soap:operation soapAction=""/>
         <input>
  -        <soap:body use="literal"/>
  +        <soap:body use="encoded"/>
         </input>
         <output>
          <mime:multipartRelated>
             <mime:part>
  -            <soap:body parts="body" use="literal"/>
  -          </mime:part>
  -          <mime:part>
  -            <mime:content part="docs" type="text/html"/>
  -          </mime:part>
  -          <mime:part>
  -            <mime:content part="logo" type="image/gif"/>
  -            <mime:content part="logo" type="image/jpeg"/>
  +            <mime:content part="body" type="text/plain"/>
             </mime:part>
           </mime:multipartRelated>
         </output>
       </operation>
  -    <operation name="GetCompanyInfo2">
  -      <soap:operation soapAction="http://example.com/GetCompanyInfo2"/>
  +    <operation name="inputMimeMultipart">
  +      <soap:operation soapAction=""/>
         <input>
          <mime:multipartRelated>
             <mime:part>
  -            <soap:body parts="body" use="literal"/>
  -          </mime:part>
  -          <mime:part>
  -            <mime:content part="docs" type="text/plain"/>
  -          </mime:part>
  -          <mime:part>
  -            <mime:content part="logo" type="image/gif"/>
  -            <mime:content part="logo" type="image/jpeg"/>
  +            <mime:content part="body" type="multipart/related"/>
             </mime:part>
           </mime:multipartRelated>
         </input>
         <output>
  -        <soap:body use="literal"/>
  +        <soap:body use="encoded"/>
         </output>
       </operation>
  --->
  -    <operation name="inputPlainText">
  +    <operation name="inoutMimeMultipart">
         <soap:operation soapAction=""/>
         <input>
          <mime:multipartRelated>
             <mime:part>
  -            <mime:content part="body" type="text/plain"/>
  +            <mime:content part="body" type="multipart/related"/>
             </mime:part>
           </mime:multipartRelated>
         </input>
         <output>
  -<!--        <soap:body use="literal"/>   Note:  turning on the literal
  flag causes problems:  "SimpleDeser cannot handle structured data!".  Two
  problems:  1.  why?  2.  I believe literal is supposed to be the default.
  It doesn't seem to be in AXIS.  -->
  +       <mime:multipartRelated>
  +          <mime:part>
  +            <mime:content part="body" type="multipart/related"/>
  +          </mime:part>
  +        </mime:multipartRelated>
         </output>
       </operation>
  -    <operation name="echoPlainText">
  +    <operation name="echoMimeMultipart">
         <soap:operation soapAction=""/>
         <input>
          <mime:multipartRelated>
             <mime:part>
  -            <mime:content part="body" type="text/plain"/>
  +            <mime:content part="body" type="multipart/related"/>
             </mime:part>
           </mime:multipartRelated>
         </input>
         <output>
          <mime:multipartRelated>
             <mime:part>
  -            <mime:content part="body" type="text/plain"/>
  +            <mime:content part="out" type="multipart/related"/>
             </mime:part>
           </mime:multipartRelated>
         </output>
       </operation>
  -<!-- This operation fails and I can't figure out why at the moment...
  -    <operation name="outputPlainText">
  +    <operation name="outputMimeMultipart">
         <soap:operation soapAction=""/>
         <input>
  -<!-        <soap:body use="literal"/>  Note:  turning on the literal
  flag causes problems:  "SimpleDeser cannot handle structured data!".  Two
  problems:  1.  why?  2.  I believe literal is supposed to be the default.
  It doesn't seem to be in AXIS.  ->
  +        <soap:body use="encoded"/>
         </input>
         <output>
          <mime:multipartRelated>
             <mime:part>
  -            <mime:content part="body" type="text/plain"/>
  +            <mime:content part="body" type="multipart/related"/>
             </mime:part>
           </mime:multipartRelated>
         </output>
       </operation>
  --->
     </binding>

  +<!-- I want to do a document style binding, too, but it doesn't work yet
  -->
  +
     <service name="Attachment">
       <port name="AttachmentPortRPC" binding="tns:b1">
         <soap:address location="http://localhost:
       8080/axis/services/AttachmentPortRPC"/>
       </port>
  +<!-- doc doesn't work yet
       <port name="AttachmentPortDoc" binding="tns:b2">
         <soap:address location="http://localhost:
       8080/axis/services/AttachmentPortDoc"/>
       </port>
  +-->
     </service>

   </wsdl:definitions>




Re: Changing WDSDL2Java symbol table slightly (was: Re: cvs commit: xml-axis/java/test/wsdl/attachments mime.wsdl)

Posted by Davanum Srinivas <di...@yahoo.com>.
No Obejections from me...

Thanks,
dims
--- butek@us.ibm.com wrote:
> This note is particularly for dims, but anyone who uses the symbol table
> from WSDL2Java might be affected.  There are a couple notes from my recent
> commit like:
> 
> +        if (parms.returnType != null) {
> +            // Construct a Parameter for the return.
> +            // RJB NOTE:  The return info should really just be a
> Parameter
> +            //            rather than duplicating the same info on the
> +            //            Parameters object.
> +            Parameter returnParm = new Parameter();
> +            returnParm.setMIMEType(parms.returnMIMEType);
> +            returnParm.setType(parms.returnType);
> +            ret = Utils.getParameterTypeName(returnParm);
> +        }
> 
> Unless someone objects to my changing things on them, I want to change org.
> apache.axis.wsdl.symbolTable.Parameters.  I'll remove:
> 
>     public TypeEntry returnType = null;
>     public QName returnName = null;
>     public String returnMIMEType = null;
> 
> and replace it with:
> 
>     public Parameter returnParam = null;
> 
> And fix the rest of the code accordingly.
> 
> Any objections?
> 
> Russell Butek
> butek@us.ibm.com
> 
> 
> butek@apache.org on 08/02/2002 07:55:34 AM
> 
> Please respond to axis-dev@xml.apache.org
> 
> To:    xml-axis-cvs@apache.org
> cc:
> Subject:    cvs commit: xml-axis/java/test/wsdl/attachments mime.wsdl
> 
> 
> 
> butek       2002/08/02 05:55:34
> 
>   Modified:    java/src/org/apache/axis/description ParameterDesc.java
>                         ServiceDesc.java
>                java/src/org/apache/axis/providers/java RPCProvider.java
>                java/src/org/apache/axis/utils JavaUtils.java
>                java/src/org/apache/axis/wsdl/symbolTable BindingEntry.java
>                         SymbolTable.java
>                java/src/org/apache/axis/wsdl/toJava
>                         JavaGeneratorFactory.java JavaSkelWriter.java
>                         JavaStubWriter.java JavaTestCaseWriter.java
>                         Utils.java
>                java/test/wsdl/attachments mime.wsdl
>   Log:
>   One more small step toward full attachment support.  WSDL2Java now
>   supports javax.mail.internet.MimeMultipart.
> 
>   Revision  Changes    Path
>   1.16      +5 -2      xml-
>   axis/java/src/org/apache/axis/description/ParameterDesc.java
> 
>   Index: ParameterDesc.java
>   ===================================================================
>   RCS file: /home/cvs/xml-
>   axis/java/src/org/apache/axis/description/ParameterDesc.java,v
>   retrieving revision 1.15
>   retrieving revision 1.16
>   diff -u -r1.15 -r1.16
>   --- ParameterDesc.java      26 Jul 2002 14:57:48 -0000    1.15
>   +++ ParameterDesc.java      2 Aug 2002 12:55:33 -0000     1.16
>   @@ -140,8 +140,11 @@
>                                             "INOUT" : "OUT:  "
>                                             + "position:" + order) + "\n";
>            text+=indent + "isReturn:   " + isReturn + "\n";
>   -        text+=indent + "typeQName:  " + typeQName+ "\n";
>   -        text+=indent + "javaType:   " + javaType+ "\n";
>   +        text+=indent + "typeQName:  " + typeQName + "\n";
>   +        text+=indent + "javaType:   " + javaType + "\n";
>   +        if (mimeType != null) {
>   +            text+=indent + "MIMEType:   " + mimeType + "\n";
>   +        }
>            return text;
>        } // toString
> 
> 
> 
> 
>   1.44      +11 -1     xml-
>   axis/java/src/org/apache/axis/description/ServiceDesc.java
> 
>   Index: ServiceDesc.java
>   ===================================================================
>   RCS file: /home/cvs/xml-
>   axis/java/src/org/apache/axis/description/ServiceDesc.java,v
>   retrieving revision 1.43
>   retrieving revision 1.44
>   diff -u -r1.43 -r1.44
>   --- ServiceDesc.java  29 Jul 2002 19:20:50 -0000    1.43
>   +++ ServiceDesc.java  2 Aug 2002 12:55:33 -0000     1.44
>   @@ -586,7 +586,9 @@
>                            // This is a match if the paramClass is somehow
>                            // convertable to the "real" parameter type.  If
>                            not,
>                            // break out of this loop.
>   -                        if (!JavaUtils.isConvertable(paramClass,
>   heldType)) {
>   +                        if (!JavaUtils.isConvertable(paramClass,
>   heldType) &&
>   +                                !isMimeConvertable(
>   +                                param.getMIMEType(), heldType)) {
>                                break;
>                            }
>                        }
>   @@ -623,6 +625,14 @@
>                syncOperationToClass(oper, superClass);
>            }
>        }
>   +
>   +    /**
>   +     * Is this is a MIME type and is it convertible to the given type?
>   +     */
>   +    private boolean isMimeConvertable(String mimeType, Class cls) {
>   +        return mimeType != null &&
>   +                cls.getName().equals(JavaUtils.mimeToJava(mimeType));
>   +    } // isMimeConvertable
> 
>        /**
>         * Fill in a service description by introspecting the implementation
> 
> 
> 
>   1.81      +10 -0     xml-
>   axis/java/src/org/apache/axis/providers/java/RPCProvider.java
> 
>   Index: RPCProvider.java
>   ===================================================================
>   RCS file: /home/cvs/xml-
>   axis/java/src/org/apache/axis/providers/java/RPCProvider.java,v
>   retrieving revision 1.80
>   retrieving revision 1.81
>   diff -u -r1.80 -r1.81
>   --- RPCProvider.java  26 Jul 2002 14:57:48 -0000    1.80
>   +++ RPCProvider.java  2 Aug 2002 12:55:33 -0000     1.81
>   @@ -59,6 +59,7 @@
>    import org.apache.axis.Constants;
>    import org.apache.axis.MessageContext;
>    import org.apache.axis.attachments.AttachmentPart;
>   +import org.apache.axis.attachments.MimeMultipartDataSource;
>    import org.apache.axis.attachments.PlainTextDataSource;
>    import org.apache.axis.enum.Style;
>    import org.apache.axis.description.OperationDesc;
>   @@ -77,6 +78,7 @@
>    import org.apache.commons.logging.Log;
> 
>    import javax.activation.DataHandler;
>   +import javax.mail.internet.MimeMultipart;
>    import javax.xml.namespace.QName;
>    import javax.xml.rpc.holders.Holder;
>    import java.lang.reflect.Method;
>   @@ -331,6 +333,10 @@
>                        objRes = new DataHandler(new PlainTextDataSource(
>                                "ret", (String) objRes));
>                    }
>   +                else if (mimeType.startsWith("multipart/")) {
>   +                    objRes = new DataHandler(new
>   MimeMultipartDataSource(
>   +                            "ret", (MimeMultipart) objRes));
>   +                }
>                }
>                RPCParam param = new RPCParam(returnQName, objRes);
>                param.setParamDesc(operation.getReturnParamDesc());
>   @@ -351,6 +357,10 @@
>                        if (mimeType.equals("text/plain")) {
>                            value = new DataHandler(
>                                    new PlainTextDataSource("out", (String)
>                                    value));
>   +                    }
>   +                    else if (mimeType.startsWith("multipart/")) {
>   +                        value = new DataHandler(new
>   MimeMultipartDataSource(
>   +                                "out", (MimeMultipart) value));
>                        }
>                    }
>                    param.setValue(value);
> 
> 
> 
>   1.62      +29 -3     xml-axis/java/src/org/apache/axis/utils/JavaUtils.
>   java
> 
>   Index: JavaUtils.java
>   ===================================================================
>   RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/JavaUtils.
>   java,v
>   retrieving revision 1.61
>   retrieving revision 1.62
> 
=== message truncated ===


=====
Davanum Srinivas - http://xml.apache.org/~dims/

__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com