dims        2002/12/06 10:21:41

  Modified:    java     build.xml
               java/src/org/apache/axis/deployment/wsdd WSDDConstants.java
                        WSDDProvider.java
               java/src/org/apache/axis/deployment/wsdd/providers
                        WSDDComProvider.java
               java/src/org/apache/axis/providers BSFProvider.java
                        BasicProvider.java ComProvider.java
               java/xmls targets.xml
  Log:
  Initial Impl of COM Provider.
  
  Notes:
  - Need DLL's and java code from COMBridge in proposals directory 
(http://cvs.apache.org/viewcvs.cgi/xml-axis/proposals/COMBridge/)
  - See deploy.wsdd in the proposals/COMBridge directory. It deploys the xml-soap 
sample APACHEADDER.DLL 
(http://cvs.apache.org/viewcvs.cgi/xml-soap/java/samples/com/server/)
  
  Revision  Changes    Path
  1.218     +1 -0      xml-axis/java/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/build.xml,v
  retrieving revision 1.217
  retrieving revision 1.218
  diff -u -r1.217 -r1.218
  --- build.xml 5 Dec 2002 18:02:55 -0000       1.217
  +++ build.xml 6 Dec 2002 18:21:40 -0000       1.218
  @@ -118,6 +118,7 @@
         <exclude name="**/org/apache/axis/handlers/MD5AttachHandler.java" 
unless="attachments.present"/>
         <exclude name="**/org/apache/axis/handlers/SOAPMonitorHandler.java" 
unless="servlet.present"/>
         <exclude name="**/org/apache/axis/monitor/SOAPMonitorService.java" 
unless="servlet.present"/>
  +      <exclude name="**/org/apache/axis/providers/ComProvider.java" 
unless="combridge.present"/>
         <exclude name="**/org/apache/axis/transport/http/AdminServlet.java" 
unless="servlet.present"/>
         <exclude name="**/org/apache/axis/transport/http/AxisHttpSession.java" 
unless="servlet.present"/>
         <exclude name="**/org/apache/axis/transport/http/AxisServlet.java" 
unless="servlet.present"/>
  
  
  
  1.30      +1 -0      
xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDConstants.java
  
  Index: WSDDConstants.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDConstants.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- WSDDConstants.java        5 Dec 2002 18:02:55 -0000       1.29
  +++ WSDDConstants.java        6 Dec 2002 18:21:40 -0000       1.30
  @@ -112,6 +112,7 @@
       public static final QName QNAME_JAVAMSG_PROVIDER = new QName(URI_WSDD_JAVA, 
PROVIDER_MSG);
       public static final QName QNAME_HANDLER_PROVIDER = new QName("", 
PROVIDER_HANDLER);
       public static final QName QNAME_EJB_PROVIDER     = new QName(URI_WSDD_JAVA, 
PROVIDER_EJB);
  +    public static final QName QNAME_COM_PROVIDER = new QName(URI_WSDD_JAVA, 
PROVIDER_COM);
       public static final QName QNAME_BSF_PROVIDER = new QName(URI_WSDD_JAVA, 
PROVIDER_BSF);
       public static final QName QNAME_CORBA_PROVIDER = new QName(URI_WSDD_JAVA, 
PROVIDER_CORBA);
       public static final QName QNAME_RMI_PROVIDER = new QName(URI_WSDD_JAVA, 
PROVIDER_RMI);
  
  
  
  1.28      +2 -0      
xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDProvider.java
  
  Index: WSDDProvider.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDProvider.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- WSDDProvider.java 5 Dec 2002 18:02:56 -0000       1.27
  +++ WSDDProvider.java 6 Dec 2002 18:21:40 -0000       1.28
  @@ -61,6 +61,7 @@
   import org.apache.axis.deployment.wsdd.providers.WSDDJavaEJBProvider;
   import org.apache.axis.deployment.wsdd.providers.WSDDJavaMsgProvider;
   import org.apache.axis.deployment.wsdd.providers.WSDDJavaRPCProvider;
  +import org.apache.axis.deployment.wsdd.providers.WSDDComProvider;
   import org.apache.axis.deployment.wsdd.providers.WSDDJavaCORBAProvider;
   import org.apache.axis.deployment.wsdd.providers.WSDDJavaRMIProvider;
   import org.apache.axis.deployment.wsdd.providers.WSDDBsfProvider;
  @@ -105,6 +106,7 @@
           providers.put(WSDDConstants.QNAME_JAVAMSG_PROVIDER, new 
WSDDJavaMsgProvider());
           providers.put(WSDDConstants.QNAME_HANDLER_PROVIDER, new 
WSDDHandlerProvider());
           providers.put(WSDDConstants.QNAME_EJB_PROVIDER, new WSDDJavaEJBProvider());
  +        providers.put(WSDDConstants.QNAME_COM_PROVIDER, new WSDDComProvider());
           providers.put(WSDDConstants.QNAME_BSF_PROVIDER, new WSDDBsfProvider());
           providers.put(WSDDConstants.QNAME_CORBA_PROVIDER, new 
WSDDJavaCORBAProvider());
           providers.put(WSDDConstants.QNAME_RMI_PROVIDER, new WSDDJavaRMIProvider());
  
  
  
  1.21      +7 -11     
xml-axis/java/src/org/apache/axis/deployment/wsdd/providers/WSDDComProvider.java
  
  Index: WSDDComProvider.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/providers/WSDDComProvider.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- WSDDComProvider.java      25 Oct 2002 17:18:34 -0000      1.20
  +++ WSDDComProvider.java      6 Dec 2002 18:21:40 -0000       1.21
  @@ -59,7 +59,6 @@
   import org.apache.axis.deployment.wsdd.WSDDProvider;
   import org.apache.axis.deployment.wsdd.WSDDService;
   import org.apache.axis.providers.BasicProvider;
  -import org.apache.axis.providers.ComProvider;
   import org.apache.axis.utils.ClassUtils;
   import org.apache.axis.deployment.wsdd.WSDDConstants;
   import org.apache.axis.deployment.wsdd.WSDDConstants;
  @@ -71,6 +70,9 @@
   public class WSDDComProvider
       extends WSDDProvider
   {
  +    public static final String OPTION_PROGID = "ProgID";
  +    public static final String OPTION_THREADING_MODEL = "threadingModel";
  +    
       public String getName() {
           return WSDDConstants.PROVIDER_COM;
       }
  @@ -79,26 +81,20 @@
                                          EngineConfiguration registry)
           throws Exception
       {
  -        Class _class = 
ClassUtils.forName("org.apache.axis.handlers.providers.ComProvider");
  +        Class _class = ClassUtils.forName("org.apache.axis.providers.ComProvider");
   
           BasicProvider provider = (BasicProvider) _class.newInstance();
   
           String option = service.getParameter("ProgID");
   
           if (!option.equals("")) {
  -            provider.setOption(ComProvider.OPTION_PROGID, option);
  -        }
  -
  -        option = service.getParameter("CLSID");
  -
  -        if (!option.equals("")) {
  -            provider.setOption(ComProvider.OPTION_CLSID, option);
  +            provider.setOption(OPTION_PROGID, option);
           }
   
           option = service.getParameter("threadingModel");
   
  -        if (!option.equals("")) {
  -            provider.setOption(ComProvider.OPTION_THREADING_MODEL, option);
  +        if (option!= null && !option.equals("")) {
  +            provider.setOption(OPTION_THREADING_MODEL, option);
           }
   
           return provider;
  
  
  
  1.8       +1 -153    xml-axis/java/src/org/apache/axis/providers/BSFProvider.java
  
  Index: BSFProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/BSFProvider.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BSFProvider.java  5 Dec 2002 18:02:56 -0000       1.7
  +++ BSFProvider.java  6 Dec 2002 18:21:41 -0000       1.8
  @@ -86,22 +86,11 @@
       protected static Log log =
               LogFactory.getLog(BSFProvider.class.getName());
   
  -    // The enterprise category is for stuff that an enterprise product might
  -    // want to track, but in a simple environment (like the AXIS build) would
  -    // be nothing more than a nuisance.
  -    protected static Log entLog =
  -            LogFactory.getLog(Constants.ENTERPRISE_LOG_CATEGORY);
   
       public static final String OPTION_LANGUAGE = "language";
       public static final String OPTION_SRC = "src";
       public static final String OPTION_SCRIPT = "script";
   
  -    public static final String OPTION_WSDL_PORTTYPE = "wsdlPortType";
  -    public static final String OPTION_WSDL_SERVICEELEMENT = "wsdlServiceElement";
  -    public static final String OPTION_WSDL_SERVICEPORT = "wsdlServicePort";
  -    public static final String OPTION_WSDL_TARGETNAMESPACE = "wsdlTargetNamespace";
  -    public static final String OPTION_WSDL_INPUTSCHEMA = "wsdlInputSchema";
  -
       public void invoke(MessageContext msgContext) throws AxisFault {
           try {
               SOAPService service = msgContext.getService();
  @@ -109,7 +98,7 @@
               String scriptStr = (String) service.getOption(OPTION_SRC);
   
               if (log.isDebugEnabled()) {
  -                log.debug("Enter: RPCProvider.processMessage()");
  +                log.debug("Enter: BSFProvider.processMessage()");
               }
   
               OperationDesc operation = msgContext.getOperation();
  @@ -234,147 +223,6 @@
   
       public void initServiceDesc(SOAPService service, MessageContext msgContext)
               throws AxisFault {
  -    }
  -
  -    /**
  -     * Generate the WSDL for this service.
  -     *
  -     * Put in the "WSDL" property of the message context
  -     * as a org.w3c.dom.Document
  -     */
  -    public void generateWSDL(MessageContext msgContext) throws AxisFault {
  -        if (log.isDebugEnabled())
  -            log.debug("Enter: BSFProvider::generateWSDL (" + this + ")");
  -
  -        /* Find the service we're invoking so we can grab it's options */
  -        /***************************************************************/
  -        SOAPService service = msgContext.getService();
  -        ServiceDesc serviceDesc = service.getInitializedServiceDesc(msgContext);
  -
  -        // Calculate the appropriate namespaces for the WSDL we're going
  -        // to put out.
  -        //
  -        // If we've been explicitly told which namespaces to use, respect
  -        // that.  If not:
  -        //
  -        // The "interface namespace" should be either:
  -        // 1) The namespace of the ServiceDesc
  -        // 2) The transport URL (if there's no ServiceDesc ns)
  -
  -        try {
  -            // Location URL is whatever is explicitly set in the MC
  -            String locationUrl =
  -                    msgContext.getStrProp(MessageContext.WSDLGEN_SERV_LOC_URL);
  -
  -            if (locationUrl == null) {
  -                // If nothing, try what's explicitly set in the ServiceDesc
  -                locationUrl = serviceDesc.getEndpointURL();
  -            }
  -
  -            if (locationUrl == null) {
  -                // If nothing, use the actual transport URL
  -                locationUrl = msgContext.getStrProp(MessageContext.TRANS_URL);
  -            }
  -
  -            // Interface namespace is whatever is explicitly set
  -            String interfaceNamespace =
  -                    msgContext.getStrProp(MessageContext.WSDLGEN_INTFNAMESPACE);
  -
  -            if (interfaceNamespace == null) {
  -                // If nothing, use the default namespace of the ServiceDesc
  -                interfaceNamespace = serviceDesc.getDefaultNamespace();
  -            }
  -
  -            if (interfaceNamespace == null) {
  -                // If nothing still, use the location URL determined above
  -                interfaceNamespace = locationUrl;
  -            }
  -
  -//  Do we want to do this?
  -//
  -//            if (locationUrl == null) {
  -//                locationUrl = url;
  -//            } else {
  -//                try {
  -//                    URL urlURL = new URL(url);
  -//                    URL locationURL = new URL(locationUrl);
  -//                    URL urlTemp = new URL(urlURL.getProtocol(),
  -//                            locationURL.getHost(),
  -//                            locationURL.getPort(),
  -//                            urlURL.getFile());
  -//                    interfaceNamespace += urlURL.getFile();
  -//                    locationUrl = urlTemp.toString();
  -//                } catch (Exception e) {
  -//                    locationUrl = url;
  -//                    interfaceNamespace = url;
  -//                }
  -//            }
  -
  -            Emitter emitter = new Emitter();
  -
  -            // Set the name for the target service.
  -            emitter.setServiceElementName(serviceDesc.getName());
  -            
  -            // service alias may be provided if exact naming is required,
  -            // otherwise Axis will name it according to the implementing class name
  -            String alias = (String) service.getOption("alias");
  -            if (alias != null) emitter.setServiceElementName(alias);
  -
  -            // Set style/use
  -            emitter.setStyle(serviceDesc.getStyle());
  -            emitter.setUse(serviceDesc.getUse());
  -
  -            emitter.setClsSmart(serviceDesc.getImplClass(), locationUrl);
  -
  -            // If a wsdl target namespace was provided, use the targetNamespace.
  -            // Otherwise use the interfaceNamespace constructed above.
  -            String targetNamespace = (String) 
service.getOption(OPTION_WSDL_TARGETNAMESPACE);
  -            if (targetNamespace == null ||
  -                    targetNamespace.length() == 0) {
  -                targetNamespace = interfaceNamespace;
  -            }
  -            emitter.setIntfNamespace(targetNamespace);
  -
  -            emitter.setLocationUrl(locationUrl);
  -            emitter.setServiceDesc(serviceDesc);
  -            emitter.setTypeMapping((TypeMapping) msgContext.getTypeMappingRegistry()
  -                    .getTypeMapping(serviceDesc.getUse().getEncoding()));
  -            emitter.setDefaultTypeMapping((TypeMapping) 
msgContext.getTypeMappingRegistry().
  -                    getDefaultTypeMapping());
  -
  -            String wsdlPortType = (String) service.getOption(OPTION_WSDL_PORTTYPE);
  -            String wsdlServiceElement = (String) 
service.getOption(OPTION_WSDL_SERVICEELEMENT);
  -            String wsdlServicePort = (String) 
service.getOption(OPTION_WSDL_SERVICEPORT);
  -
  -            if (wsdlPortType != null && wsdlPortType.length() > 0) {
  -                emitter.setPortTypeName(wsdlPortType);
  -            }
  -            if (wsdlServiceElement != null && wsdlServiceElement.length() > 0) {
  -                emitter.setServiceElementName(wsdlServiceElement);
  -            }
  -            if (wsdlServicePort != null && wsdlServicePort.length() > 0) {
  -                emitter.setServicePortName(wsdlServicePort);
  -            }
  -
  -            String wsdlInputSchema = (String)
  -                    service.getOption(OPTION_WSDL_INPUTSCHEMA);
  -            if (null != wsdlInputSchema && wsdlInputSchema.length() > 0) {
  -                emitter.setInputSchema(wsdlInputSchema);
  -            }
  -
  -            Document doc = emitter.emit(Emitter.MODE_ALL);
  -
  -            msgContext.setProperty("WSDL", doc);
  -        } catch (NoClassDefFoundError e) {
  -            entLog.info(Messages.getMessage("toAxisFault00"), e);
  -            throw new AxisFault(e.toString(), e);
  -        } catch (Exception e) {
  -            entLog.info(Messages.getMessage("toAxisFault00"), e);
  -            throw AxisFault.makeFault(e);
  -        }
  -
  -        if (log.isDebugEnabled())
  -            log.debug("Exit: JavaProvider::generateWSDL (" + this + ")");
       }
   }
   
  
  
  
  1.13      +163 -0    xml-axis/java/src/org/apache/axis/providers/BasicProvider.java
  
  Index: BasicProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/BasicProvider.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- BasicProvider.java        6 Aug 2002 03:55:05 -0000       1.12
  +++ BasicProvider.java        6 Dec 2002 18:21:41 -0000       1.13
  @@ -59,6 +59,14 @@
   import org.apache.axis.handlers.soap.SOAPService;
   import org.apache.axis.AxisFault;
   import org.apache.axis.MessageContext;
  +import org.apache.axis.Constants;
  +import org.apache.axis.components.logger.LogFactory;
  +import org.apache.axis.utils.Messages;
  +import org.apache.axis.encoding.TypeMapping;
  +import org.apache.axis.wsdl.fromJava.Emitter;
  +import org.apache.axis.description.ServiceDesc;
  +import org.apache.commons.logging.Log;
  +import org.w3c.dom.Document;
   
   import javax.xml.namespace.QName;
   
  @@ -71,6 +79,21 @@
    */
   public abstract class BasicProvider extends BasicHandler {
       
  +    public static final String OPTION_WSDL_PORTTYPE = "wsdlPortType";
  +    public static final String OPTION_WSDL_SERVICEELEMENT = "wsdlServiceElement";
  +    public static final String OPTION_WSDL_SERVICEPORT = "wsdlServicePort";
  +    public static final String OPTION_WSDL_TARGETNAMESPACE = "wsdlTargetNamespace";
  +    public static final String OPTION_WSDL_INPUTSCHEMA = "wsdlInputSchema";
  +
  +    protected static Log log =
  +            LogFactory.getLog(BasicProvider.class.getName());
  +
  +    // The enterprise category is for stuff that an enterprise product might
  +    // want to track, but in a simple environment (like the AXIS build) would
  +    // be nothing more than a nuisance.
  +    protected static Log entLog =
  +            LogFactory.getLog(Constants.ENTERPRISE_LOG_CATEGORY);
  +    
       /**
        * This method returns a ServiceDesc that contains the correct 
        * implimentation class. 
  @@ -112,4 +135,144 @@
           return names;
       }
       
  +    /**
  +     * Generate the WSDL for this service.
  +     *
  +     * Put in the "WSDL" property of the message context
  +     * as a org.w3c.dom.Document
  +     */
  +    public void generateWSDL(MessageContext msgContext) throws AxisFault {
  +        if (log.isDebugEnabled())
  +            log.debug("Enter: BSFProvider::generateWSDL (" + this + ")");
  +
  +        /* Find the service we're invoking so we can grab it's options */
  +        /***************************************************************/
  +        SOAPService service = msgContext.getService();
  +        ServiceDesc serviceDesc = service.getInitializedServiceDesc(msgContext);
  +
  +        // Calculate the appropriate namespaces for the WSDL we're going
  +        // to put out.
  +        //
  +        // If we've been explicitly told which namespaces to use, respect
  +        // that.  If not:
  +        //
  +        // The "interface namespace" should be either:
  +        // 1) The namespace of the ServiceDesc
  +        // 2) The transport URL (if there's no ServiceDesc ns)
  +
  +        try {
  +            // Location URL is whatever is explicitly set in the MC
  +            String locationUrl =
  +                    msgContext.getStrProp(MessageContext.WSDLGEN_SERV_LOC_URL);
  +
  +            if (locationUrl == null) {
  +                // If nothing, try what's explicitly set in the ServiceDesc
  +                locationUrl = serviceDesc.getEndpointURL();
  +            }
  +
  +            if (locationUrl == null) {
  +                // If nothing, use the actual transport URL
  +                locationUrl = msgContext.getStrProp(MessageContext.TRANS_URL);
  +            }
  +
  +            // Interface namespace is whatever is explicitly set
  +            String interfaceNamespace =
  +                    msgContext.getStrProp(MessageContext.WSDLGEN_INTFNAMESPACE);
  +
  +            if (interfaceNamespace == null) {
  +                // If nothing, use the default namespace of the ServiceDesc
  +                interfaceNamespace = serviceDesc.getDefaultNamespace();
  +            }
  +
  +            if (interfaceNamespace == null) {
  +                // If nothing still, use the location URL determined above
  +                interfaceNamespace = locationUrl;
  +            }
  +
  +//  Do we want to do this?
  +//
  +//            if (locationUrl == null) {
  +//                locationUrl = url;
  +//            } else {
  +//                try {
  +//                    URL urlURL = new URL(url);
  +//                    URL locationURL = new URL(locationUrl);
  +//                    URL urlTemp = new URL(urlURL.getProtocol(),
  +//                            locationURL.getHost(),
  +//                            locationURL.getPort(),
  +//                            urlURL.getFile());
  +//                    interfaceNamespace += urlURL.getFile();
  +//                    locationUrl = urlTemp.toString();
  +//                } catch (Exception e) {
  +//                    locationUrl = url;
  +//                    interfaceNamespace = url;
  +//                }
  +//            }
  +
  +            Emitter emitter = new Emitter();
  +
  +            // Set the name for the target service.
  +            emitter.setServiceElementName(serviceDesc.getName());
  +            
  +            // service alias may be provided if exact naming is required,
  +            // otherwise Axis will name it according to the implementing class name
  +            String alias = (String) service.getOption("alias");
  +            if (alias != null) emitter.setServiceElementName(alias);
  +
  +            // Set style/use
  +            emitter.setStyle(serviceDesc.getStyle());
  +            emitter.setUse(serviceDesc.getUse());
  +
  +            emitter.setClsSmart(serviceDesc.getImplClass(), locationUrl);
  +
  +            // If a wsdl target namespace was provided, use the targetNamespace.
  +            // Otherwise use the interfaceNamespace constructed above.
  +            String targetNamespace = (String) 
service.getOption(OPTION_WSDL_TARGETNAMESPACE);
  +            if (targetNamespace == null ||
  +                    targetNamespace.length() == 0) {
  +                targetNamespace = interfaceNamespace;
  +            }
  +            emitter.setIntfNamespace(targetNamespace);
  +
  +            emitter.setLocationUrl(locationUrl);
  +            emitter.setServiceDesc(serviceDesc);
  +            emitter.setTypeMapping((TypeMapping) msgContext.getTypeMappingRegistry()
  +                    .getTypeMapping(serviceDesc.getUse().getEncoding()));
  +            emitter.setDefaultTypeMapping((TypeMapping) 
msgContext.getTypeMappingRegistry().
  +                    getDefaultTypeMapping());
  +
  +            String wsdlPortType = (String) service.getOption(OPTION_WSDL_PORTTYPE);
  +            String wsdlServiceElement = (String) 
service.getOption(OPTION_WSDL_SERVICEELEMENT);
  +            String wsdlServicePort = (String) 
service.getOption(OPTION_WSDL_SERVICEPORT);
  +
  +            if (wsdlPortType != null && wsdlPortType.length() > 0) {
  +                emitter.setPortTypeName(wsdlPortType);
  +            }
  +            if (wsdlServiceElement != null && wsdlServiceElement.length() > 0) {
  +                emitter.setServiceElementName(wsdlServiceElement);
  +            }
  +            if (wsdlServicePort != null && wsdlServicePort.length() > 0) {
  +                emitter.setServicePortName(wsdlServicePort);
  +            }
  +
  +            String wsdlInputSchema = (String)
  +                    service.getOption(OPTION_WSDL_INPUTSCHEMA);
  +            if (null != wsdlInputSchema && wsdlInputSchema.length() > 0) {
  +                emitter.setInputSchema(wsdlInputSchema);
  +            }
  +
  +            Document doc = emitter.emit(Emitter.MODE_ALL);
  +
  +            msgContext.setProperty("WSDL", doc);
  +        } catch (NoClassDefFoundError e) {
  +            entLog.info(Messages.getMessage("toAxisFault00"), e);
  +            throw new AxisFault(e.toString(), e);
  +        } catch (Exception e) {
  +            entLog.info(Messages.getMessage("toAxisFault00"), e);
  +            throw AxisFault.makeFault(e);
  +        }
  +
  +        if (log.isDebugEnabled())
  +            log.debug("Exit: JavaProvider::generateWSDL (" + this + ")");
  +    }
   }
  
  
  
  1.7       +157 -7    xml-axis/java/src/org/apache/axis/providers/ComProvider.java
  
  Index: ComProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/ComProvider.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ComProvider.java  6 Aug 2002 12:11:31 -0000       1.6
  +++ ComProvider.java  6 Dec 2002 18:21:41 -0000       1.7
  @@ -55,17 +55,167 @@
   
   package org.apache.axis.providers;
   
  -import org.apache.axis.MessageContext;
   import org.apache.axis.AxisFault;
  +import org.apache.axis.Constants;
  +import org.apache.axis.Message;
  +import org.apache.axis.MessageContext;
  +import org.apache.axis.deployment.wsdd.providers.WSDDComProvider;
  +import org.apache.axis.components.bridge.COMBridge;
  +import org.apache.axis.description.OperationDesc;
  +import org.apache.axis.description.ParameterDesc;
   import org.apache.axis.handlers.soap.SOAPService;
  +import org.apache.axis.message.RPCElement;
  +import org.apache.axis.message.RPCHeaderParam;
  +import org.apache.axis.message.RPCParam;
  +import org.apache.axis.message.SOAPBodyElement;
  +import org.apache.axis.message.SOAPEnvelope;
  +import org.apache.axis.soap.SOAPConstants;
  +import org.apache.axis.utils.JavaUtils;
  +import org.apache.axis.utils.Messages;
  +
  +import javax.xml.namespace.QName;
  +import java.util.Hashtable;
  +import java.util.Vector;
   
   public class ComProvider extends BasicProvider {
  -    
  -    public static final String OPTION_PROGID = "ProgID";
  -    public static final String OPTION_CLSID = "CLSID";
  -    public static final String OPTION_THREADING_MODEL = "threadingModel";
  -    
  -    public void invoke(MessageContext msgContext) {
  +
  +
  +    public void invoke(MessageContext msgContext) throws AxisFault {
  +        try {
  +            SOAPService service = msgContext.getService();
  +            String progID = (String) 
service.getOption(WSDDComProvider.OPTION_PROGID);
  +            String threadingModel = (String) 
service.getOption(WSDDComProvider.OPTION_THREADING_MODEL);
  +
  +            if (log.isDebugEnabled()) {
  +                log.debug("Enter: COMProvider.processMessage()");
  +            }
  +
  +            OperationDesc operation = msgContext.getOperation();
  +
  +            Vector bodies = 
msgContext.getRequestMessage().getSOAPEnvelope().getBodyElements();
  +            if (log.isDebugEnabled()) {
  +                log.debug(Messages.getMessage("bodyElems00", "" + bodies.size()));
  +                log.debug(Messages.getMessage("bodyIs00", "" + bodies.get(0)));
  +            }
  +
  +            RPCElement body = null;
  +            
  +            // Find the first "root" body element, which is the RPC call.
  +            for (int bNum = 0; body == null && bNum < bodies.size(); bNum++) {
  +                // If this is a regular old SOAPBodyElement, and it's a root,
  +                // we're probably a non-wrapped doc/lit service.  In this case,
  +                // we deserialize the element, and create an RPCElement "wrapper"
  +                // around it which points to the correct method.
  +                // FIXME : There should be a cleaner way to do this...
  +                if (!(bodies.get(bNum) instanceof RPCElement)) {
  +                    SOAPBodyElement bodyEl = (SOAPBodyElement) bodies.get(bNum);
  +                    // igors: better check if bodyEl.getID() != null
  +                    // to make sure this loop does not step on SOAP-ENC objects
  +                    // that follow the parameters! FIXME?
  +                    if (bodyEl.isRoot() && operation != null && bodyEl.getID() == 
null) {
  +                        ParameterDesc param = operation.getParameter(bNum);
  +                        // at least do not step on non-existent parameters!
  +                        if (param != null) {
  +                            Object val = 
bodyEl.getValueAsType(param.getTypeQName());
  +                            body = new RPCElement("",
  +                                    operation.getName(),
  +                                    new Object[]{val});
  +                        }
  +                    }
  +                } else {
  +                    body = (RPCElement) bodies.get(bNum);
  +                }
  +            }
  +
  +            String methodName = body.getMethodName();
  +            Vector args = body.getParams();
  +            int numArgs = args.size();
  +
  +            Vector argValues = new Vector();
  +            
  +            // Put the values contained in the RPCParams into an array
  +            // suitable for passing to java.lang.reflect.Method.invoke()
  +            // Make sure we respect parameter ordering if we know about it
  +            // from metadata, and handle whatever conversions are necessary
  +            // (values -> Holders, etc)
  +            for (int i = 0; i < numArgs; i++) {
  +                RPCParam rpcParam = (RPCParam) args.get(i);
  +                Object value = rpcParam.getValue();
  +
  +                // first check the type on the paramter
  +                ParameterDesc paramDesc = rpcParam.getParamDesc();
  +
  +                // if we found some type info try to make sure the value type is
  +                // correct.  For instance, if we deserialized a xsd:dateTime in
  +                // to a Calendar and the service takes a Date, we need to convert
  +                if (paramDesc != null && paramDesc.getJavaType() != null) {
  +
  +                    // Get the type in the signature (java type or its holder)
  +                    Class sigType = paramDesc.getJavaType();
  +
  +                    // Convert the value into the expected type in the signature
  +                    value = JavaUtils.convert(value,
  +                            sigType);
  +
  +                    rpcParam.setValue(value);
  +                }
  +                argValues.add(value);
  +            }
  +
  +            COMBridge bridge = new COMBridge();
  +            Hashtable props = new Hashtable();
  +            props.put("progid", progID);
  +            if (threadingModel != null)
  +                props.put("threadmodel", threadingModel);
  +
  +            Object result = bridge.execute(methodName, argValues, props);
  +
  +            RPCElement resBody = new RPCElement(methodName + "Response");
  +            resBody.setPrefix(body.getPrefix());
  +            resBody.setNamespaceURI(body.getNamespaceURI());
  +            resBody.setEncodingStyle(msgContext.getEncodingStyle());
  +
  +            Message resMsg = msgContext.getResponseMessage();
  +            SOAPEnvelope resEnv;
  +
  +            // If we didn't have a response message, make sure we set one up
  +            if (resMsg == null) {
  +                resEnv = new SOAPEnvelope(msgContext.getSOAPConstants());
  +
  +                resMsg = new Message(resEnv);
  +                msgContext.setResponseMessage(resMsg);
  +            } else {
  +                resEnv = resMsg.getSOAPEnvelope();
  +            }
  +
  +            QName returnQName = operation.getReturnQName();
  +            if (returnQName == null) {
  +                returnQName = new QName("", methodName + "Return");
  +            }
  +
  +            // For SOAP 1.2, add a result
  +            if (msgContext.getSOAPConstants() ==
  +                    SOAPConstants.SOAP12_CONSTANTS) {
  +                returnQName = Constants.QNAME_RPC_RESULT;
  +            }
  +
  +            RPCParam param = new RPCParam(returnQName, result);
  +            param.setParamDesc(operation.getReturnParamDesc());
  +            if (!operation.isReturnHeader()) {
  +                resBody.addParam(param);
  +            } else {
  +                resEnv.addHeader(new RPCHeaderParam(param));
  +            }
  +
  +            resEnv.addBodyElement(resBody);
  +
  +        } catch (Exception e) {
  +            entLog.debug(Messages.getMessage("toAxisFault00"), e);
  +            throw AxisFault.makeFault(e);
  +        } catch (Throwable t) {
  +            entLog.debug(Messages.getMessage("toAxisFault00"));
  +            throw new AxisFault(Messages.getMessage("toAxisFault00"), t);
  +        }
       }
   
       public void initServiceDesc(SOAPService service, MessageContext msgContext)
  
  
  
  1.50      +4 -0      xml-axis/java/xmls/targets.xml
  
  Index: targets.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/xmls/targets.xml,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- targets.xml       5 Dec 2002 18:02:56 -0000       1.49
  +++ targets.xml       6 Dec 2002 18:21:41 -0000       1.50
  @@ -205,6 +205,10 @@
         <available classname="com.ibm.bsf.BSFManager" classpathref="classpath" />
       </condition>
   
  +    <condition property="combridge.present" >
  +      <available classname="org.apache.axis.components.bridge.COMBridge" 
classpathref="classpath" />
  +    </condition>
  +
       <!-- look for WSDL support on the platform -->
       <condition property="wsdl.found">
         <or>
  
  
  


Reply via email to