dims        2002/12/05 10:02:56

  Modified:    java     build.xml
               java/src/org/apache/axis/deployment/wsdd WSDDConstants.java
                        WSDDProvider.java
               java/src/org/apache/axis/providers BSFProvider.java
               java/src/org/apache/axis/wsdl/fromJava Emitter.java
               java/xmls targets.xml
  Added:       java/src/org/apache/axis/components/script BSF.java
                        Script.java ScriptFactory.java
  Log:
  BSF Provider - Initial commit
  
  Notes:
  1. Needs BSF jar and Rhino jar
  2. Script is specified in the wsdd itself (like Apache SOAP)
  3. WSDL is generated from information present in WSDD as well.
  4. Here's a sample deploy.wsdd
  <deployment
      xmlns="http://xml.apache.org/axis/wsdd/";
      xmlns:java="http://xml.apache.org/axis/wsdd/providers/java";>
    <service name="plus" provider="java:BSF" style="rpc" use="encoded">
        <parameter name="language" value="javascript"/>
        <parameter name="src" value="function plus (x, y) {return x + y;}"/>
        <parameter name="wsdlTargetNamespace" value="urn:javascript"/>
        <parameter name="wsdlServiceElement" value="JSService"/>
        <parameter name="wsdlServicePort" value="plus"/>
        <parameter name="wsdlPortType" value="plus"/>
        <operation name="plus" qname="operNS:plus" 
xmlns:operNS="http://DefaultNamespace"; returnQName="plusReturn" 
returnType="rtns:double" xmlns:rtns="http://www.w3.org/2001/XMLSchema"; >
          <parameter name="in0" type="tns:double" 
xmlns:tns="http://www.w3.org/2001/XMLSchema"/>
          <parameter name="in1" type="tns:double" 
xmlns:tns="http://www.w3.org/2001/XMLSchema"/>
        </operation>
        <parameter name="allowedMethods" value="plus"/>
    </service>
  </deployment>
  
  Revision  Changes    Path
  1.217     +1 -0      xml-axis/java/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/build.xml,v
  retrieving revision 1.216
  retrieving revision 1.217
  diff -u -r1.216 -r1.217
  --- build.xml 4 Dec 2002 04:16:16 -0000       1.216
  +++ build.xml 5 Dec 2002 18:02:55 -0000       1.217
  @@ -131,6 +131,7 @@
         <exclude 
name="**/org/apache/axis/components/jms/JMSVendorAdapterFactory.java" 
unless="jms.present"/>
         <exclude name="**/org/apache/axis/components/jms/JNDIVendorAdapter.java" 
unless="jms.present"/>
         <exclude name="**/org/apache/axis/components/jms/SonicMQVendorAdapter.java" 
unless="jmsAndSonicMQ.present"/>
  +      <exclude name="**/org/apache/axis/components/script/BSF.java" 
unless="bsf.present"/>
         <exclude name="**/org/apache/axis/server/JNDIAxisServerFactory.java" 
unless="servlet.present"/>
         <exclude name="**/org/apache/axis/security/servlet/*" 
unless="servlet.present"/>
         <exclude name="**/javax/xml/soap/*.java" unless="attachments.present"/>
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/components/script/BSF.java
  
  Index: BSF.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.components.script;
  
  import com.ibm.bsf.BSFEngine;
  import com.ibm.bsf.BSFManager;
  
  public class BSF implements Script {
      public Object run(String language, String name, String scriptStr, String 
methodName, Object[] argValues)
              throws Exception {
          BSFManager manager = new BSFManager();
          BSFEngine engine = manager.loadScriptingEngine(language);
  
          manager.exec(language, "service script for '" +
                  name + "'", 0, 0, scriptStr);
  
          Object result = engine.call(null, methodName, argValues);
          return result;
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/components/script/Script.java
  
  Index: Script.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.components.script;
  
  /**
   * This interface defines a Script module functionality
   * @author <a href="mailto:[EMAIL PROTECTED]";>Davanum Srinivas</a>
   * @version $Revision: 1.1 $ $Date: 2002/12/05 18:02:55 $
   * @since 2.0
   */
  public interface Script {
      public Object run(String language, String name, String scriptStr, String 
methodName, Object[] argValues)
              throws Exception;
  }
  
  
  
  
  1.1                  
xml-axis/java/src/org/apache/axis/components/script/ScriptFactory.java
  
  Index: ScriptFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.components.script;
  
  import org.apache.axis.AxisProperties;
  import org.apache.axis.components.logger.LogFactory;
  import org.apache.commons.logging.Log;
  
  /**
   * This class implements a factory to instantiate an Script component.
   * @author <a href="mailto:[EMAIL PROTECTED]";>Davanum Srinivas</a>
   * @version $Revision: 1.1 $ $Date: 2002/12/05 18:02:55 $
   * @since 2.0
   */
  public class ScriptFactory {
      protected static Log log =
              LogFactory.getLog(ScriptFactory.class.getName());
  
      static {
          AxisProperties.setClassOverrideProperty(Script.class, "axis.Script");
  
          AxisProperties.setClassDefaults(Script.class,
                  new String[]{
                      "org.apache.axis.components.script.BSF",
                  });
      }
  
      /**
       * Get the Script implementation. 
       */
      public static Script getScript() {
          Script script = (Script) AxisProperties.newInstance(Script.class);
          log.debug("axis.Script: " + script.getClass().getName());
          return script;
      }
  }
  
  
  
  
  
  1.29      +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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- WSDDConstants.java        5 Dec 2002 15:02:53 -0000       1.28
  +++ WSDDConstants.java        5 Dec 2002 18:02:55 -0000       1.29
  @@ -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_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.27      +4 -2      
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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- WSDDProvider.java 5 Dec 2002 15:02:53 -0000       1.26
  +++ WSDDProvider.java 5 Dec 2002 18:02:56 -0000       1.27
  @@ -63,6 +63,7 @@
   import org.apache.axis.deployment.wsdd.providers.WSDDJavaRPCProvider;
   import org.apache.axis.deployment.wsdd.providers.WSDDJavaCORBAProvider;
   import org.apache.axis.deployment.wsdd.providers.WSDDJavaRMIProvider;
  +import org.apache.axis.deployment.wsdd.providers.WSDDBsfProvider;
   import org.apache.axis.utils.JavaUtils;
   import org.apache.axis.utils.Messages;
   
  @@ -104,6 +105,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_BSF_PROVIDER, new WSDDBsfProvider());
           providers.put(WSDDConstants.QNAME_CORBA_PROVIDER, new 
WSDDJavaCORBAProvider());
           providers.put(WSDDConstants.QNAME_RMI_PROVIDER, new WSDDJavaRMIProvider());
           try {
  @@ -137,7 +139,7 @@
           DiscoverServiceNames dsn = new DiscoverServiceNames(loaders);
           ResourceNameIterator iter = 
dsn.findResourceNames(PLUGABLE_PROVIDER_FILENAME);
           while (iter.hasNext()) {
  -            String className = (String) iter.nextResourceName();
  +            String className = iter.nextResourceName();
               try {
                   Object o = Class.forName(className).newInstance();
                   if (o instanceof WSDDProvider) {
  @@ -157,7 +159,7 @@
       /**
        *
        * @param uri XXX
  -     * @param _class XXX
  +     * @param prov XXX
        */
       public static void registerProvider(QName uri, WSDDProvider prov)
       {
  
  
  
  1.7       +312 -8    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BSFProvider.java  6 Aug 2002 12:11:31 -0000       1.6
  +++ BSFProvider.java  5 Dec 2002 18:02:56 -0000       1.7
  @@ -55,22 +55,326 @@
   
   package org.apache.axis.providers;
   
  -import org.apache.axis.MessageContext;
   import org.apache.axis.AxisFault;
  -import org.apache.axis.handlers.soap.SOAPService;
  +import org.apache.axis.Constants;
  +import org.apache.axis.Message;
  +import org.apache.axis.MessageContext;
  +import org.apache.axis.components.logger.LogFactory;
  +import org.apache.axis.components.script.ScriptFactory;
  +import org.apache.axis.components.script.Script;
  +import org.apache.axis.description.OperationDesc;
  +import org.apache.axis.description.ParameterDesc;
   import org.apache.axis.description.ServiceDesc;
  +import org.apache.axis.encoding.TypeMapping;
  +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 org.apache.axis.wsdl.fromJava.Emitter;
  +import org.apache.commons.logging.Log;
  +import org.w3c.dom.Document;
  +
  +import javax.xml.namespace.QName;
  +import java.util.Vector;
   
   public class BSFProvider extends BasicProvider {
  +    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();
  +            String language = (String) service.getOption(OPTION_LANGUAGE);
  +            String scriptStr = (String) service.getOption(OPTION_SRC);
  +
  +            if (log.isDebugEnabled()) {
  +                log.debug("Enter: RPCProvider.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();
  +
  +            Object[] argValues = new Object[numArgs];
  +            
  +            // 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[i] = value;
  +            }
  +
  +            Script script = ScriptFactory.getScript();
  +            Object result = script.run(language, service.getName(), scriptStr, 
methodName, argValues);
  +
  +            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;
  +            }
   
  -    public static final String OPTION_LANGUAGE = "Language";
  -    public static final String OPTION_SRC = "Src";
  -    public static final String OPTION_SCRIPT = "Script";
  -    
  -    public void invoke(MessageContext msgContext) {
  -        System.out.println(getOption("Script"));
  +            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);
  +        }
       }
   
       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.78      +9 -7      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.77
  retrieving revision 1.78
  diff -u -r1.77 -r1.78
  --- Emitter.java      29 Nov 2002 23:48:22 -0000      1.77
  +++ Emitter.java      5 Dec 2002 18:02:56 -0000       1.78
  @@ -511,11 +511,11 @@
           }
   
           if (encodingList == null) {
  -            clsName = cls.getName();
  -            clsName = clsName.substring(clsName.lastIndexOf('.') + 1);
  -
               // Default the portType name
               if (getPortTypeName() == null) {
  +                clsName = cls.getName();
  +                clsName = clsName.substring(clsName.lastIndexOf('.') + 1);
  +
                   setPortTypeName(clsName);
               }
   
  @@ -570,7 +570,8 @@
                   }
               }
   
  -            namespaces.put(cls.getName(), intfNS, "intf");
  +            if(cls != null)
  +                namespaces.put(cls.getName(), intfNS, "intf");
               namespaces.putPrefix(implNS, "impl");
           }
       }
  @@ -1269,9 +1270,10 @@
               // Add the type representing the param
               // For convenience, add an element for the param
               // Write <part name=param_name type=param_type>
  -            QName typeQName = 
  -                types.writeTypeForPart(javaType,
  -                                       param.getTypeQName());
  +            QName typeQName = param.getTypeQName();
  +            if(javaType != null)
  +                typeQName = types.writeTypeForPart(javaType,
  +                                       typeQName);
               //types.writeElementForPart(javaType, param.getTypeQName());
               if (typeQName != null) {
                   part.setName(param.getName());
  
  
  
  1.49      +3 -0      xml-axis/java/xmls/targets.xml
  
  Index: targets.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/xmls/targets.xml,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- targets.xml       19 Nov 2002 19:29:36 -0000      1.48
  +++ targets.xml       5 Dec 2002 18:02:56 -0000       1.49
  @@ -201,6 +201,9 @@
         <available classname="org.exolab.castor.xml.MarshalException" 
classpathref="classpath" />
       </condition>
   
  +    <condition property="bsf.present" >
  +      <available classname="com.ibm.bsf.BSFManager" classpathref="classpath" />
  +    </condition>
   
       <!-- look for WSDL support on the platform -->
       <condition property="wsdl.found">
  
  
  


Reply via email to