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/test/wsdl/attachments buildComponent.xml
Date Fri, 09 Aug 2002 13:56:25 GMT
butek       2002/08/09 06:56:25

  Modified:    java/src/org/apache/axis Constants.java
               java/src/org/apache/axis/description ParameterDesc.java
                        ServiceDesc.java
               java/src/org/apache/axis/encoding
                        DefaultTypeMappingImpl.java
               java/src/org/apache/axis/providers/java RPCProvider.java
               java/src/org/apache/axis/utils JavaUtils.java
               java/src/org/apache/axis/wsdl/fromJava Emitter.java
                        Types.java
               java/src/org/apache/axis/wsdl/toJava JavaDeployWriter.java
                        JavaSkelWriter.java JavaStubWriter.java Utils.java
               java/test build_functional_tests.xml
               java/test/wsdl/attachments buildComponent.xml
  Log:
  More attachment work.
  
  - we've decided to take a different approach.  Instead of following WSDL1.1
  as close as possible, which is what I started doing, we decided to deviate
  completely from WSDL1.1.  It is impossible in WSDL1.1 to have arrays of
  MIME attachments, so we had to do something else.  What we're doing is
  creating new AXIS types for MIME attachments.  WSDL2Java will still
  handle WSDL 1.1 WSDL, but Java2WSDL will never generate WSDL 1.1
  WSDL, it will generate our own flavor.  This simplified the code quite a bit.
  And now we're actually starting to pass bits of the attachments TCK test.
  
  - I've started removing the absolute dependency on activation.jar and mail.jar,
  but I'm a long way from finishing that work.
  
  - the attachment test wasn't being run (the build xml's were referring to
  "attachements" (note the extra "e")).
  
  Revision  Changes    Path
  1.77      +5 -4      xml-axis/java/src/org/apache/axis/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Constants.java,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- Constants.java	7 Aug 2002 21:02:08 -0000	1.76
  +++ Constants.java	9 Aug 2002 13:56:24 -0000	1.77
  @@ -79,8 +79,6 @@
       public static final String NS_PREFIX_WSDL_SOAP  = "wsdlsoap";
       public static final String NS_PREFIX_XMLSOAP    = "apachesoap";
       public static final String NS_PREFIX_XML        = "xml";
  -    public static final String NS_PREFIX_MIME       = "mime";
  -
   
       // Axis Namespaces
       public static final String NS_URI_AXIS = "http://xml.apache.org/axis/";
  @@ -92,8 +90,6 @@
       // {http://xml.apache.org/axis/java}org.foo.Bar
       public static final String NS_URI_JAVA = "http://xml.apache.org/axis/java";
   
  -    // WSDL MIME namespace
  -    public static final String NS_URI_WSDL_MIME = "http://schemas.xmlsoap.org/wsdl/mime/";
       //
       // SOAP-ENV Namespaces
       //
  @@ -473,6 +469,11 @@
       public static final QName SOAP_MAP = new QName(NS_URI_XMLSOAP, "Map");
       public static final QName SOAP_ELEMENT = new QName(NS_URI_XMLSOAP, "Element");
       public static final QName SOAP_VECTOR = new QName(NS_URI_XMLSOAP, "Vector");
  +    public static final QName MIME_IMAGE = new QName(NS_URI_XMLSOAP, "Image");
  +    public static final QName MIME_PLAINTEXT = new QName(NS_URI_XMLSOAP, "PlainText");
  +    public static final QName MIME_MULTIPART = new QName(NS_URI_XMLSOAP, "Multipart");
  +    public static final QName MIME_SOURCE = new QName(NS_URI_XMLSOAP, "Source");
  +    public static final QName MIME_DATA_HANDLER = new QName(NS_URI_XMLSOAP, "DataHandler");
   
   
       public static final QName QNAME_LITERAL_ITEM = new QName(URI_LITERAL_ENC,"item");
  
  
  
  1.18      +1 -25     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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ParameterDesc.java	6 Aug 2002 14:47:12 -0000	1.17
  +++ ParameterDesc.java	9 Aug 2002 13:56:24 -0000	1.18
  @@ -120,12 +120,10 @@
        * @param mode IN, OUT, INOUT
        * @param typeQName the parameter's XML type QName
        * @param javaType the parameter's javaType
  -     * @param mimeType the parameter's MIME type, if any
        */
  -    public ParameterDesc(QName name, byte mode, QName typeQName, Class javaType, String
mimeType) {
  +    public ParameterDesc(QName name, byte mode, QName typeQName, Class javaType) {
           this(name,mode,typeQName);
           this.javaType = javaType;
  -        this.mimeType = mimeType;
       }
   
       public String toString() {
  @@ -142,9 +140,6 @@
           text+=indent + "isReturn:   " + isReturn + "\n";
           text+=indent + "typeQName:  " + typeQName + "\n";
           text+=indent + "javaType:   " + javaType + "\n";
  -        if (mimeType != null) {
  -            text+=indent + "MIMEType:   " + mimeType + "\n";
  -        }
           return text;
       } // toString
       
  @@ -236,11 +231,6 @@
           }
   
           this.javaType = javaType;
  -
  -        // If it doesn't already exist, try to set the MIME type.
  -        if (mimeType == null) {
  -            mimeType = JavaUtils.javaToMIME(javaType);
  -        }
       }
   
       public byte getMode() {
  @@ -272,20 +262,6 @@
        */
       public void setIsReturn(boolean value) {
           isReturn = value;
  -    }
  -
  -    /**
  -     * Get the MIME type of this parameter.
  -     */
  -    public String getMIMEType() {
  -        return mimeType;
  -    }
  -
  -    /**
  -     * Set the MIME type of this parameter.
  -     */
  -    public void setMIMEType(String mimeType) {
  -        this.mimeType = mimeType;
       }
   
       private void writeObject(ObjectOutputStream out)
  
  
  
  1.46      +1 -11     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.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- ServiceDesc.java	5 Aug 2002 05:10:47 -0000	1.45
  +++ ServiceDesc.java	9 Aug 2002 13:56:24 -0000	1.46
  @@ -594,9 +594,7 @@
                           // 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) &&
  -                                !isMimeConvertable(
  -                                param.getMIMEType(), heldType)) {
  +                        if (!JavaUtils.isConvertable(paramClass, heldType)) {
                               break;
                           }
                       }
  @@ -633,14 +631,6 @@
               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.41      +21 -0     xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java
  
  Index: DefaultTypeMappingImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- DefaultTypeMappingImpl.java	7 Aug 2002 21:02:09 -0000	1.40
  +++ DefaultTypeMappingImpl.java	9 Aug 2002 13:56:24 -0000	1.41
  @@ -119,6 +119,12 @@
           //    This is the reason why the soap encoded primitives are
           //    registered without serializers.
   
  +        // Since the last-registered type wins, I want to add the mime
  +        // String FIRST.
  +        myRegister(Constants.MIME_PLAINTEXT, java.lang.String.class,
  +                new JAFDataHandlerSerializerFactory(),
  +                new JAFDataHandlerDeserializerFactory(), false);
  +
           // SOAP Encoded strings are treated as primitives.
           // Everything else is not.
           // Note that only deserializing is supported since we are flowing
  @@ -319,6 +325,21 @@
                      new VectorDeserializerFactory(java.util.Vector.class,
                                                    Constants.SOAP_VECTOR),
                      false);
  +
  +        // Register all the supported MIME types
  +        // (note that MIME_PLAINTEXT was registered near the top)
  +        myRegister(Constants.MIME_IMAGE, java.awt.Image.class,
  +                new JAFDataHandlerSerializerFactory(),
  +                new JAFDataHandlerDeserializerFactory(), false);
  +        myRegister(Constants.MIME_MULTIPART, javax.mail.internet.MimeMultipart.class,
  +                new JAFDataHandlerSerializerFactory(),
  +                new JAFDataHandlerDeserializerFactory(), false);
  +        myRegister(Constants.MIME_SOURCE, javax.xml.transform.Source.class,
  +                new JAFDataHandlerSerializerFactory(),
  +                new JAFDataHandlerDeserializerFactory(), false);
  +        myRegister(Constants.MIME_DATA_HANDLER, javax.activation.DataHandler.class,
  +                new JAFDataHandlerSerializerFactory(),
  +                new JAFDataHandlerDeserializerFactory(), false);
   
           // xsd:token
           myRegister(Constants.XSD_TOKEN, org.apache.axis.types.Token.class,
  
  
  
  1.83      +40 -16    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.82
  retrieving revision 1.83
  diff -u -r1.82 -r1.83
  --- RPCProvider.java	5 Aug 2002 05:10:47 -0000	1.82
  +++ RPCProvider.java	9 Aug 2002 13:56:24 -0000	1.83
  @@ -79,7 +79,11 @@
   import javax.mail.internet.MimeMultipart;
   import javax.xml.namespace.QName;
   import javax.xml.rpc.holders.Holder;
  +
  +import java.io.IOException;
  +
   import java.lang.reflect.Method;
  +
   import java.util.Vector;
   import java.util.Iterator;
   import java.util.ArrayList;
  @@ -225,6 +229,11 @@
                   // Convert the value into the expected type in the signature
                   value = JavaUtils.convert(value,
                                             sigType);
  +
  +                if (value instanceof DataHandler) {
  +                    value = getDataFromDataHandler((DataHandler) value, paramDesc);
  +                }
  +
                   rpcParam.setValue(value);
                   if (paramDesc.getMode() == ParameterDesc.INOUT) {
                       outs.add(rpcParam);
  @@ -319,17 +328,6 @@
                   resBody.addParam(result);
               }
   
  -            String mimeType = operation.getReturnParamDesc().getMIMEType();
  -            if (mimeType != null) {
  -                if (mimeType.equals("text/plain")) {
  -                    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());
               resBody.addParam(param);
  @@ -343,17 +341,25 @@
                   Holder holder = (Holder)param.getValue();
                   Object value = JavaUtils.getHolderValue(holder);
                   ParameterDesc paramDesc = param.getParamDesc();
  -                String mimeType = paramDesc == null ? null :
  -                        paramDesc.getMIMEType();
  -                if (mimeType != null) {
  -                    if (mimeType.equals("text/plain")) {
  +
  +                // Check for a MIME attachment outputs
  +                QName paramQName = paramDesc == null ? null : paramDesc.getTypeQName();
  +                if (paramQName != null && paramQName.getNamespaceURI().equals(Constants.NS_URI_XMLSOAP))
{
  +                    // We have a potential attachment, put the parameter
  +                    // into a DataHandler.
  +                    String MIMEName = paramQName.getLocalPart();
  +                    if ("Image".equals(MIMEName)) {
  +                    }
  +                    else if ("PlainText".equals(MIMEName)) {
                           value = new DataHandler(
                                   new PlainTextDataSource("out", (String) value));
                       }
  -                    else if (mimeType.startsWith("multipart/")) {
  +                    else if ("Multipart".equals(MIMEName)) {
                           value = new DataHandler(new MimeMultipartDataSource(
                                   "out", (MimeMultipart) value));
                       }
  +                    else if ("Source".equals(MIMEName)) {
  +                    }
                   }
                   param.setValue(value);
                   resBody.addParam(param);
  @@ -362,6 +368,24 @@
   
           resEnv.addBodyElement(resBody);
       }
  +
  +    private Object getDataFromDataHandler(DataHandler handler, ParameterDesc paramDesc)
{
  +        Object value = handler;
  +        QName qname = paramDesc.getTypeQName();
  +        if (qname != null &&
  +                (qname.equals(Constants.MIME_IMAGE) ||
  +                 qname.equals(Constants.MIME_PLAINTEXT) ||
  +                 qname.equals(Constants.MIME_MULTIPART) ||
  +                 qname.equals(Constants.MIME_SOURCE))) {
  +            try {
  +                value = handler.getContent();
  +            }
  +            catch (IOException ioe) {
  +                // If there are any problems, just return the DataHandler.
  +            }
  +        }
  +        return value;
  +    } // getDataFromDataHandler
   
       /**
        * This method encapsulates the method invocation.             
  
  
  
  1.66      +25 -28    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.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- JavaUtils.java	7 Aug 2002 21:02:08 -0000	1.65
  +++ JavaUtils.java	9 Aug 2002 13:56:24 -0000	1.66
  @@ -83,7 +83,7 @@
   import java.util.List;
   import java.beans.Introspector;
   
  -import javax.mail.internet.MimeMultipart;
  +import javax.activation.DataHandler;
   
   import javax.xml.soap.SOAPException;
   
  @@ -240,11 +240,21 @@
           }
   
           // Convert an AttachmentPart to the given destination class.
  -        if (arg instanceof AttachmentPart) {
  +        if (arg instanceof AttachmentPart || arg instanceof DataHandler) {
               try {
  +                String destName = destClass.getName();
                   if (destClass == String.class
  -                        || destClass == MimeMultipart.class) {
  -                    return ((AttachmentPart)arg).getDataHandler().getContent();
  +                        || destClass == java.awt.Image.class
  +                        || destName.equals("javax.mail.internet.MimeMultipart")
  +                        || destName.equals("javax.xml.transform.Source")) {
  +                    DataHandler handler;
  +                    if (arg instanceof AttachmentPart) {
  +                        handler = ((AttachmentPart) arg).getDataHandler();
  +                    }
  +                    else {
  +                        handler = (DataHandler) arg;
  +                    }
  +                    return handler.getContent();
                   }
               }
               catch (IOException ioe) {
  @@ -472,6 +482,17 @@
                   return true;
           }
   
  +        // If it's a MIME type mapping and we want a DataHandler,
  +        // then we're good.
  +        if (dest.getName().equals("javax.activation.DataHandler")) {
  +            String name = src.getName();
  +            if (src == String.class
  +                    || src == java.awt.Image.class
  +                    || name.equals("javax.mail.internet.MimeMultipart")
  +                    || name.equals("javax.xml.transform.Source"))
  +                return true;
  +        }
  +
           return false;
       }
       
  @@ -1085,28 +1106,4 @@
               return null;
           }
       } // mimeToJava
  -
  -    /**
  -     * Given a Java type, return the MIME type string mapping
  -     */
  -    public static String javaToMIME(Class javaType) {
  -        if (javaType != null) {
  -            if (java.awt.Image.class.isAssignableFrom(javaType)) {
  -                return "image/jpeg";
  -            }
  -            else if (javax.xml.transform.Source.class.isAssignableFrom(javaType)) {
  -                return "text/xml";
  -            }
  -            else if (javax.mail.internet.MimeMultipart.class.isAssignableFrom(
  -                    javaType)) {
  -                return "multipart/related";
  -            }
  -            else if (javax.activation.DataHandler.class.isAssignableFrom(
  -                    javaType)) {
  -                return "";
  -            }
  -        }
  -        return null;
  -    } // javaToMIME
  -
   }
  
  
  
  1.59      +3 -102    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.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- Emitter.java	6 Aug 2002 14:47:12 -0000	1.58
  +++ Emitter.java	9 Aug 2002 13:56:24 -0000	1.59
  @@ -55,10 +55,6 @@
   
   package org.apache.axis.wsdl.fromJava;
   
  -import com.ibm.wsdl.extensions.mime.MIMEContentImpl;
  -import com.ibm.wsdl.extensions.mime.MIMEPartImpl;
  -import com.ibm.wsdl.extensions.mime.MIMEMultipartRelatedImpl;
  -
   import com.ibm.wsdl.extensions.soap.SOAPAddressImpl;
   import com.ibm.wsdl.extensions.soap.SOAPBindingImpl;
   import com.ibm.wsdl.extensions.soap.SOAPBodyImpl;
  @@ -95,10 +91,6 @@
   
   import javax.wsdl.extensions.ExtensibilityElement;
   
  -import javax.wsdl.extensions.mime.MIMEContent;
  -import javax.wsdl.extensions.mime.MIMEPart;
  -import javax.wsdl.extensions.mime.MIMEMultipartRelated;
  -
   import javax.wsdl.extensions.soap.SOAPAddress;
   import javax.wsdl.extensions.soap.SOAPBinding;
   import javax.wsdl.extensions.soap.SOAPBody;
  @@ -881,24 +873,13 @@
   
           // Input clause
           ExtensibilityElement input = null;
  -        if (hasMIMEParameter(desc, ParameterDesc.IN)) {
  -            input = writeMIMEMultipart(desc, ParameterDesc.IN,
  -                    desc.getElementQName());
  -        }
  -        else {
  -            input = writeSOAPBody(desc.getElementQName());
  -        }
  +        input = writeSOAPBody(desc.getElementQName());
           bindingInput.addExtensibilityElement(input);
   
           //Output clause
           ExtensibilityElement output = null;
  -        if (hasMIMEParameter(desc, ParameterDesc.OUT)) {
  -            output = writeMIMEMultipart(desc, ParameterDesc.OUT,
  -                    desc.getReturnQName());
  -        }
  -        else {
  -            output = writeSOAPBody(desc.getReturnQName());
  -        }
  +        output = writeSOAPBody(desc.getReturnQName());
  +
           bindingOutput.addExtensibilityElement(output);
   
           bindingOper.setBindingInput(bindingInput);
  @@ -909,77 +890,6 @@
           return bindingOper;
       }
   
  -    private boolean hasMIMEParameter(OperationDesc oper, byte mode) {
  -        ArrayList parameters = oper.getParameters();
  -        for (int i = 0; i < parameters.size(); ++i) {
  -            ParameterDesc parameter = (ParameterDesc) parameters.get(i);
  -            if (parameter.getMIMEType() != null
  -                    && (parameter.getMode() & mode) != 0) {
  -                return true;
  -            }
  -        }
  -        // We also have to look at the return if we want info about
  -        // output parameters.
  -        if (mode == ParameterDesc.OUT) {
  -            ParameterDesc ret = oper.getReturnParamDesc();
  -            if (ret != null && ret.getMIMEType() != null) {
  -                return true;
  -            }
  -        }
  -
  -        return false;
  -    } // hassMIMEParameter
  -
  -    private ExtensibilityElement writeMIMEMultipart(OperationDesc oper,
  -            byte mode, QName operQName) {
  -        MIMEMultipartRelated mprelated = new MIMEMultipartRelatedImpl();
  -        ArrayList parameters = oper.getParameters();
  -        for (int i = 0; i < parameters.size(); ++i) {
  -            ParameterDesc parameter = (ParameterDesc) parameters.get(i);
  -            if ((parameter.getMode() & mode) != 0) {
  -                MIMEPart mimePart = writeMIMEPart(parameter, operQName);
  -                mprelated.addMIMEPart(mimePart);
  -            }
  -        }
  -
  -        // We also have to look at the return if we want info about
  -        // output parameters.
  -        if (mode == ParameterDesc.OUT) {
  -            ParameterDesc ret = oper.getReturnParamDesc();
  -            if (ret != null) {
  -                MIMEPart mimePart = writeMIMEPart(ret, operQName);
  -                mprelated.addMIMEPart(mimePart);
  -            }
  -        }
  -
  -        return mprelated;
  -    } // writeMIMEMultipart
  -
  -    private MIMEPart writeMIMEPart(ParameterDesc parameter, QName operQName) {
  -        String mimeType = parameter.getMIMEType();
  -        MIMEPart mimePart = new MIMEPartImpl();
  -        ExtensibilityElement mimeContent = null;
  -        if (mimeType == null) {
  -            mimeContent = writeSOAPBody(operQName);
  -        }
  -        else {
  -            mimeContent = writeMIMEContent(parameter.getName(), mimeType);
  -        }
  -        mimePart.addExtensibilityElement(mimeContent);
  -        return mimePart;
  -    } // writeMIMEPart
  -
  -    private MIMEContent writeMIMEContent(String part, String type) {
  -        // If the part is null, then it MUST be a return part
  -        if (part == null) {
  -            part = "return";
  -        }
  -        MIMEContent mimeContent = new MIMEContentImpl();
  -        mimeContent.setPart(part);
  -        mimeContent.setType(type);
  -        return mimeContent;
  -    } // writeMIMEContent
  -
       private ExtensibilityElement writeSOAPBody(QName operQName) {
           SOAPBody soapBody = new SOAPBodyImpl();
           // for now, if its document, it is literal use.
  @@ -1156,15 +1066,6 @@
           if (param.getMode() != ParameterDesc.IN &&
               param.getIsReturn() == false) {
               javaType = JavaUtils.getHolderValueType(javaType);
  -        }
  -
  -        // If this is a MIME type, make sure the MIME namespace is in
  -        // the Definition
  -        if (JavaUtils.javaToMIME(javaType) != null && def.getNamespace(Constants.NS_PREFIX_MIME)
== null) {
  -            def.addNamespace(Constants.NS_PREFIX_MIME,
  -                    Constants.NS_URI_WSDL_MIME);
  -            namespaces.putPrefix(Constants.NS_URI_WSDL_MIME,
  -                    Constants.NS_PREFIX_MIME);
           }
   
           // Write the type representing the parameter type
  
  
  
  1.54      +0 -16     xml-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java
  
  Index: Types.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- Types.java	6 Aug 2002 14:47:12 -0000	1.53
  +++ Types.java	9 Aug 2002 13:56:24 -0000	1.54
  @@ -262,14 +262,6 @@
               return qname;
           }
   
  -        // For MIME types, just use xsd:string since the xml type is
  -        // ignored by WSDL2Java anyway.  NOTE:  This probably is not
  -        // good enough for the long haul, but it'll do today (ie., for
  -        // the TCK).
  -        if (JavaUtils.javaToMIME(type) != null) {
  -            return Constants.XSD_STRING;
  -        }
  -
           if (wsdlTypesElem == null) {
               writeWsdlTypesElement();
           }
  @@ -499,14 +491,6 @@
           if (qName == null ||
               Constants.equals(Constants.SOAP_ARRAY, qName)) {
               qName = getTypeQName(type);
  -        }
  -
  -        // For MIME types, just use xsd:string since the xml type is
  -        // ignored by WSDL2Java anyway.  NOTE:  This probably is not
  -        // good enough for the long haul, but it'll do today (ie., for
  -        // the TCK).
  -        if (JavaUtils.javaToMIME(type) != null) {
  -            return Constants.NS_PREFIX_SCHEMA_XSD + ":string";
           }
   
           // Quick return if schema type
  
  
  
  1.57      +2 -2      xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java
  
  Index: JavaDeployWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- JavaDeployWriter.java	8 Aug 2002 15:17:11 -0000	1.56
  +++ JavaDeployWriter.java	9 Aug 2002 13:56:25 -0000	1.57
  @@ -357,7 +357,7 @@
                       QName returnType = null;
                       if (params.returnParam != null) {
                           returnQName = params.returnParam.getQName();
  -                        returnType = Utils.getXSIType(params.returnParam.getType());
  +                        returnType = Utils.getXSIType(params.returnParam);
                       }
   
                       // Write the operation metadata
  @@ -415,7 +415,7 @@
   
               // Get the parameter name QName and type QName
               QName paramQName = param.getQName();
  -            QName paramType = Utils.getXSIType(param.getType());
  +            QName paramType = Utils.getXSIType(param);
   
               if (param.getMIMEType() != null) {
                   paramType = new QName(
  
  
  
  1.43      +3 -17     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.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- JavaSkelWriter.java	8 Aug 2002 15:17:11 -0000	1.42
  +++ JavaSkelWriter.java	9 Aug 2002 13:56:25 -0000	1.43
  @@ -178,21 +178,13 @@
   
                       // Get the QNames representing the parameter name and type
                       QName paramName = p.getQName();
  -                    QName paramType = Utils.getXSIType(p.getType());
  -                    String mimeType = p.getMIMEType();
  -                    if (mimeType == null) {
  -                        mimeType = "null";
  -                    }
  -                    else {
  -                        mimeType = '"' + mimeType + '"';
  -                    }
  +                    QName paramType = Utils.getXSIType(p);
                       pw.println("            " +
                           "new org.apache.axis.description.ParameterDesc(" +
                           Utils.getNewQName(paramName) +
                           ", " + modeStr +
                           ", " + Utils.getNewQName(paramType) +
  -                        ", " + Utils.getParameterTypeName(p) + ".class" +
  -                        ", " + mimeType + "), ");
  +                        ", " + Utils.getParameterTypeName(p) + ".class), ");
                   }
   
                   pw.println("        };");
  @@ -202,7 +194,7 @@
                   QName retType = null;
                   if (parameters.returnParam != null) {
                       retName = parameters.returnParam.getQName();
  -                    retType = Utils.getXSIType(parameters.returnParam.getType());
  +                    retType = Utils.getXSIType(parameters.returnParam);
                   }
   
                   String returnStr;
  @@ -217,12 +209,6 @@
                   if (retType != null) {
                       pw.println("        _oper.setReturnType(" +
                                  Utils.getNewQName(retType) + ");");            
  -                }
  -
  -                // Is the return type a MIME type?
  -                if (parameters.returnParam != null &&
  -                            parameters.returnParam.getMIMEType() != null) {
  -                    pw.println("        _oper.getReturnParamDesc().setMIMEType(\"" + parameters.returnParam.getMIMEType()
+ "\");");
                   }
   
                   // If we need to know the QName (if we have a namespace or
  
  
  
  1.82      +14 -17    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.81
  retrieving revision 1.82
  diff -u -r1.81 -r1.82
  --- JavaStubWriter.java	8 Aug 2002 15:17:11 -0000	1.81
  +++ JavaStubWriter.java	9 Aug 2002 13:56:25 -0000	1.82
  @@ -492,16 +492,13 @@
   
               String mimeType = p.getMIMEType();
   
  -            // Get the QNames representing the parameter name and type
  -            QName paramName;
  -            QName paramType = Utils.getXSIType(p.getType());
  +            // Get the QName representing the parameter type
  +            QName paramType = Utils.getXSIType(p);
   
               // Set the javaType to the name of the type
               String javaType = null;
               if (mimeType != null) {
                   javaType = "javax.activation.DataHandler.class, ";
  -                paramName = new QName (binding.getQName().getNamespaceURI(),
  -                        "DataHandler");
               }
               else {
                   javaType = p.getType().getName();
  @@ -510,11 +507,10 @@
                   } else {
                       javaType = "";
                   }
  -                paramName = p.getQName();
               }
   
               // Get the text representing newing a QName for the name and type
  -            String paramNameText = Utils.getNewQName(paramName);
  +            String paramNameText = Utils.getNewQName(p.getQName());
               String paramTypeText = Utils.getNewQName(paramType);
   
               // Generate the addParameter call with the
  @@ -537,20 +533,25 @@
           }
           // set output type
           if (parms.returnParam != null) {
  -            TypeEntry returnType = parms.returnParam.getType();
   
               // Get the QName for the return Type
  -            QName returnName = Utils.getXSIType(returnType);
  +            QName returnName = Utils.getXSIType(parms.returnParam);
               
               // Get the javaType
  -            String javaType = returnType.getName();
  +            String javaType = null;
  +            if (parms.returnParam.getMIMEType() != null) {
  +                javaType = "javax.activation.DataHandler";
  +            }
  +            else {
  +                javaType = parms.returnParam.getType().getName();
  +            }
               if (javaType == null) {
                   pw.println("        _call.setReturnType(" + 
                              Utils.getNewQName(returnName) + ");");
               } else {
                   pw.println("        _call.setReturnType(" + 
                              Utils.getNewQName(returnName) + 
  -                           "," + javaType + ".class);");
  +                           " ," + javaType + ".class);");
               }
           }
           else {
  @@ -790,14 +791,10 @@
       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);");
  +            pw.println("                " + target + "(java.lang.String) _returnDH.getContent();");
           }
           else if (mimeType.startsWith("multipart/")) {
  -            pw.println("                " + target +
  -                    "new javax.mail.internet.MimeMultipart(_returnDH.getDataSource());");
  +            pw.println("                " + target + "(javax.mail.internet.MimeMultipart)
_returnDH.getContent();");
           }
           else {
               pw.println("                " + target +
  
  
  
  1.47      +32 -4     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.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- Utils.java	8 Aug 2002 15:17:11 -0000	1.46
  +++ Utils.java	9 Aug 2002 13:56:25 -0000	1.47
  @@ -612,12 +612,16 @@
       /** 
        * Get the QName that could be used in the xsi:type
        * when serializing an object for this parameter/return
  -     * @param te is the typeEntry from the Parameters object,
  -     *           which represents the parameter
  -     * @return the QName of the type
  +     * @param param is a parameter
  +     * @return the QName of the parameter's type
        */
  -    public static QName getXSIType(TypeEntry te) {
  +    public static QName getXSIType(Parameter param) {
  +        if (param.getMIMEType() != null) {
  +            return getMIMETypeQName(param.getMIMEType());
  +        }
  +
           QName xmlType = null;
  +        TypeEntry te = param.getType();
   
           // If the TypeEntry describes an Element, get
           // the referenced Type.
  @@ -645,6 +649,30 @@
           }
           return xmlType;
       }
  +
  +    /**
  +     * Given a MIME type, return the AXIS-specific type QName.
  +     * @param the MIME type name
  +     * @return the AXIS-specific QName for the MIME type
  +     */
  +    public static QName getMIMETypeQName(String mimeName) {
  +        if ("text/plain".equals(mimeName)) {
  +            return Constants.MIME_PLAINTEXT;
  +        }
  +        else if ("image/gif".equals(mimeName) || "image/jpeg".equals(mimeName)) {
  +            return Constants.MIME_IMAGE;
  +        }
  +        else if ("text/xml".equals(mimeName) || "applications/xml".equals(mimeName)) {
  +            return Constants.MIME_SOURCE;
  +        }
  +        else if (mimeName != null && mimeName.startsWith("multipart/")) {
  +            return Constants.MIME_MULTIPART;
  +        }
  +        else {
  +            return null;
  +        }
  +    } // getMIMEType
  +
       
       /**
        * Are there any MIME parameters in the given binding?
  
  
  
  1.54      +2 -2      xml-axis/java/test/build_functional_tests.xml
  
  Index: build_functional_tests.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/build_functional_tests.xml,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- build_functional_tests.xml	7 Aug 2002 19:26:11 -0000	1.53
  +++ build_functional_tests.xml	9 Aug 2002 13:56:25 -0000	1.54
  @@ -123,7 +123,7 @@
                 <include name="**/FunctionalTests.class" />
                 <include name="**/*TestCase.class" />
                 <exclude name="**/Interop3TestCase.class"/>
  -              <exclude name="**/test/wsdl/attachments/**/*.class" unless="attachements.present"
/>
  +              <exclude name="**/test/wsdl/attachments/**/*.class" unless="attachments.present"
/>
           </fileset>
         </batchtest>
       </junit>
  @@ -282,7 +282,7 @@
         <classpath refid="test-classpath" />
         <include name="**/*.java" />
         <exclude name="test/wsdl/interop3/**/*.java" />
  -      <exclude name="test/wsdl/attachments/**/*.java" unless="attachements.present"
/>
  +      <exclude name="test/wsdl/attachments/**/*.java" unless="attachments.present" />
       </javac>
     </target>
   
  
  
  
  1.4       +1 -1      xml-axis/java/test/wsdl/attachments/buildComponent.xml
  
  Index: buildComponent.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/attachments/buildComponent.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- buildComponent.xml	7 Aug 2002 20:22:13 -0000	1.3
  +++ buildComponent.xml	9 Aug 2002 13:56:25 -0000	1.4
  @@ -25,7 +25,7 @@
   <target name="copy" depends="setenv"/>
   
   <target name="compile" depends="copy">
  -  <echo message="Compilig test.wsdl.attachements"/>
  +  <echo message="Compilig test.wsdl.attachments"/>
       <wsdl2java url="${axis.home}/test/wsdl/attachments/mime.wsdl"
                  output="${axis.home}/build/work"
                  serverSide="yes"
  
  
  

Mime
View raw message