owenb       2002/11/25 06:58:48

  Modified:    java/src/org/apache/wsif/providers/soap/apachesoap
                        WSIFOperation_ApacheSOAP.java
  Log:
  When preparing the operation, if a type or subtype is mapped dynamically, base the 
mapping on
  the input encoding style rather than always adding a mapping for SOAP-ENC style i.e. 
use literal
  style and the PartSerializer when necessary.
  
  Revision  Changes    Path
  1.32      +97 -79    
xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apachesoap/WSIFOperation_ApacheSOAP.java
  
  Index: WSIFOperation_ApacheSOAP.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apachesoap/WSIFOperation_ApacheSOAP.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- WSIFOperation_ApacheSOAP.java     18 Nov 2002 16:45:11 -0000      1.31
  +++ WSIFOperation_ApacheSOAP.java     25 Nov 2002 14:58:48 -0000      1.32
  @@ -218,52 +218,6 @@
           return op;
       }
   
  -    //    /**
  -    //     * Creates a new input WSIFMessage. This overrides the 
  -    //     * WSIFDefaultOperation method to enable the use of 
  -    //     * compiled WSIFMessages by using a WSIFMessageFactory
  -    //     * to create the message.
  -    //     * 
  -    //     * @param name   the name of the message
  -    //     * @return a WSIFMessage instance
  -    //     * @see WSIFOperation#createInputMessage(String)
  -    //     */
  -    // defect 131672 and disable compiled msg support for now
  -    //    public WSIFMessage createInputMessage(String name) {
  -    //        Tr.entry(this, name);
  -    //        Definition d = getDefinition();
  -    //        String ns = (d == null) ? "" : d.getTargetNamespace();
  -    //        WSIFMessageFactory mf = WSIFServiceImpl.getMessageFactory();
  -    //        WSIFMessage msg = mf.createMessage(ns, name + "Message");
  -    //        if (msg != null)
  -    //            msg.setName(name);
  -    //        Tr.exit(msg);
  -    //       return msg;
  -    //    }
  -    //
  -    //    /**
  -    //     * Creates a new input WSIFMessage. This overrides the 
  -    //     * WSIFDefaultOperation method to enable the use of 
  -    //     * compiled WSIFMessages by using a WSIFMessageFactory
  -    //     * to create the message.
  -    //     * 
  -    //     * @param name   the name of the message
  -    //     * @return a WSIFMessage instance
  -    //     * @see WSIFOperation#createInputMessage(String)
  -    //     */
  -    // defect 131672 and disable compiled msg support for now
  -    //    public WSIFMessage createOutputMessage(String name) {
  -    //        Tr.entry(this, name);
  -    //        Definition d = getDefinition();
  -    //        String ns = (d == null) ? "" : d.getTargetNamespace();
  -    //        WSIFMessageFactory mf = WSIFServiceImpl.getMessageFactory();
  -    //        WSIFMessage msg = mf.createMessage(ns, name + "Message");
  -    //        if (msg != null)
  -    //            msg.setName(name);
  -    //        Tr.exit(msg);
  -    //        return msg;
  -    //    }
  -
       /**
        * Gets the target namespace URI of this WSIFOperation 
        * 
  @@ -287,6 +241,23 @@
           HashMap mapOfUserTypes = portInstance.getLocalTypeMap();
           SOAPMappingRegistry smr = portInstance.getSOAPMappingRegistry();
   
  +        // Instantiate serializers once for the entire prepare
  +        BeanSerializer beanSer = new BeanSerializer();
  +        PartSerializer partSer = null;
  +        if (partSerializerName != null) {
  +            try {
  +                partSer =
  +                    (PartSerializer) Class
  +                        .forName(
  +                            partSerializerName,
  +                            true,
  +                            Thread.currentThread().getContextClassLoader())
  +                        .newInstance();
  +            } catch (Throwable ignored) {
  +                Trc.ignoredException(ignored);
  +            }
  +        }
  +
           // first determine list of arguments
           Input input = operation.getInput();
           if (input != null) {
  @@ -348,22 +319,39 @@
                                   String className =
                                       WSIFUtils.getJavaClassNameFromXMLName(
                                           qname.getLocalPart());
  -                                Class inputClass =
  +                                Class inputClass = null;
  +                                try {
  +                                    inputClass =
                                       Class.forName(
                                           packageName + "." + className,
                                           true,
                                           Thread
                                               .currentThread()
                                               .getContextClassLoader());
  +                                } catch (ClassNotFoundException exn5) {
  +                                    inputClass =
  +                                        Class.forName(
  +                                            packageName
  +                                                + "."
  +                                                + className
  +                                                + "Element",
  +                                            true,
  +                                            Thread
  +                                                .currentThread()
  +                                                .getContextClassLoader());
  +                                }
                                   types[i] = inputClass;
  -                                BeanSerializer beanSer = new BeanSerializer();
  +                                if (inputEncodingStyle.equals("literal")) {
  +                                     smr.mapTypes("literal", qname, inputClass, 
partSer, partSer);
  +                                } else {
                                   smr.mapTypes(
                                       Constants.NS_URI_SOAP_ENC,
                                       qname,
                                       inputClass,
                                       beanSer,
                                       beanSer);
  -                                mapSubtypes(inputClass, beanSer, smr);
  +                                } 
  +                                mapSubtypes(inputClass, beanSer, partSer, smr);
                               } catch (ClassNotFoundException exn1) {
                                Trc.ignoredException(exn1);
                               }
  @@ -429,23 +417,44 @@
                                   String className =
                                       WSIFUtils.getJavaClassNameFromXMLName(
                                           qname.getLocalPart());
  -                                returnType =
  -                                    Class.forName(
  -                                        packageName + "." + className,
  -                                        true,
  -                                        Thread
  -                                            .currentThread()
  -                                            .getContextClassLoader());
  -                                BeanSerializer beanSer = new BeanSerializer();
  -                                smr.mapTypes(
  -                                    Constants.NS_URI_SOAP_ENC,
  -                                    qname,
  -                                    returnType,
  -                                    beanSer,
  -                                    beanSer);
  -                                mapSubtypes(returnType, beanSer, smr);
  +                                try {
  +                                    returnType =
  +                                        Class.forName(
  +                                            packageName + "." + className,
  +                                            true,
  +                                            Thread
  +                                                .currentThread()
  +                                                .getContextClassLoader());
  +                                } catch (ClassNotFoundException exn5) {
  +                                    returnType =
  +                                        Class.forName(
  +                                            packageName
  +                                                + "."
  +                                                + className
  +                                                + "Element",
  +                                            true,
  +                                            Thread
  +                                                .currentThread()
  +                                                .getContextClassLoader());
  +                                }
  +                                if (inputEncodingStyle.equals("literal")) {
  +                                    smr.mapTypes(
  +                                        "literal",
  +                                        qname,
  +                                        returnType,
  +                                        partSer,
  +                                        partSer);
  +                                } else {
  +                                    smr.mapTypes(
  +                                        Constants.NS_URI_SOAP_ENC,
  +                                        qname,
  +                                        returnType,
  +                                        beanSer,
  +                                        beanSer);
  +                                }
  +                                mapSubtypes(returnType, beanSer, partSer, smr);
                               } catch (ClassNotFoundException exn1) {
  -                             Trc.ignoredException(exn1);
  +                                Trc.ignoredException(exn1);
                               }
                           }
                       }
  @@ -469,13 +478,14 @@
       private void mapSubtypes(
           Class javaType,
           BeanSerializer beanSer,
  +        PartSerializer partSer,
           SOAPMappingRegistry smr) {
  -        
  +
           BeanInfo beanInfo = null;
           try {
               beanInfo = Introspector.getBeanInfo(javaType);
           } catch (IntrospectionException e) {
  -             Trc.ignoredException(e);
  +            Trc.ignoredException(e);
           }
   
           if (beanInfo != null) {
  @@ -485,11 +495,9 @@
                       Class propType = properties[i].getPropertyType();
                       try {
                           org.apache.soap.util.xml.QName qname =
  -                            smr.queryElementType(
  -                                propType,
  -                                Constants.NS_URI_SOAP_ENC);
  +                            smr.queryElementType(propType, inputEncodingStyle);
                       } catch (IllegalArgumentException exn) {
  -                     Trc.exception(exn);
  +                        Trc.exception(exn);
                           // not found in the registry - complex type, not registered
                           // before
                           if (!propType.equals(Class.class)) {
  @@ -501,16 +509,26 @@
                                       fullClassName.lastIndexOf(".") + 1);
                               org.apache.soap.util.xml.QName qname =
                                   new org.apache.soap.util.xml.QName(
  -                                    
WSIFUtils.getXSDNamespaceFromPackageName(packageName),
  +                                    WSIFUtils.getXSDNamespaceFromPackageName(
  +                                        packageName),
                                       className);
   
  -                            smr.mapTypes(
  -                                Constants.NS_URI_SOAP_ENC,
  -                                qname,
  -                                propType,
  -                                beanSer,
  -                                beanSer);
  -                            mapSubtypes(propType, beanSer, smr);
  +                            if (inputEncodingStyle.equals("literal")) {
  +                                smr.mapTypes(
  +                                    "literal",
  +                                    qname,
  +                                    propType,
  +                                    partSer,
  +                                    partSer);
  +                            } else {
  +                                smr.mapTypes(
  +                                    Constants.NS_URI_SOAP_ENC,
  +                                    qname,
  +                                    propType,
  +                                    beanSer,
  +                                    beanSer);
  +                            }
  +                            mapSubtypes(propType, beanSer, partSer, smr);
                           }
                       }
                   }
  
  
  


Reply via email to