You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by du...@apache.org on 2001/01/16 15:26:42 UTC

cvs commit: xml-soap/java/src/org/apache/soap/util Provider.java

dug         01/01/16 06:26:42

  Modified:    java/src/org/apache/soap Constants.java
               java/src/org/apache/soap/providers EntityEJBProvider.java
                        StatefulEJBProvider.java StatelessEJBProvider.java
                        TemplateProvider.java
               java/src/org/apache/soap/rpc SOAPContext.java
               java/src/org/apache/soap/server MessageRouter.java
                        RPCRouter.java ServerUtils.java
               java/src/org/apache/soap/server/http
                        MessageRouterServlet.java RPCRouterServlet.java
               java/src/org/apache/soap/util Provider.java
  Added:       java/src/org/apache/soap/providers MsgJavaProvider.java
                        RPCJavaProvider.java
  Log:
  - Added support for a bag in SOAPContext
  - Changed Plug. Providers so we use req/res SOAP Contexts
  - Add support for Plug Providers in the Messaging side of things
  
  Revision  Changes    Path
  1.12      +15 -8     xml-soap/java/src/org/apache/soap/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/Constants.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Constants.java	2001/01/08 12:25:11	1.11
  +++ Constants.java	2001/01/16 14:26:40	1.12
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2000 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2000 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -10,7 +10,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    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
  @@ -18,7 +18,7 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:  
  + *    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,
  @@ -26,7 +26,7 @@
    *
    * 4. The names "SOAP" and "Apache Software Foundation" must
    *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -86,13 +86,13 @@
       "http://www.w3.org/1999/XMLSchema-instance";
     public static final String NS_URI_SCHEMA_XSD =
       "http://www.w3.org/1999/XMLSchema";
  -  public static final String NS_URI_XML_SOAP = 
  +  public static final String NS_URI_XML_SOAP =
       "http://xml.apache.org/xml-soap";
  -  public static final String NS_URI_XML_SOAP_DEPLOYMENT = 
  +  public static final String NS_URI_XML_SOAP_DEPLOYMENT =
       "http://xml.apache.org/xml-soap/deployment";
  -  public static final String NS_URI_LITERAL_XML = 
  +  public static final String NS_URI_LITERAL_XML =
       "http://xml.apache.org/xml-soap/literalxml";
  -  public static final String NS_URI_XMI_ENC = 
  +  public static final String NS_URI_XMI_ENC =
       "http://www.ibm.com/namespaces/xmi";
   
     // HTTP header field names.
  @@ -181,4 +181,11 @@
     // Transport hook extension
     public static final String TRANSPORT_HOOK_EXTENSION =
         "org.apache.soap.TransportHookExtension";
  +
  +  // Well-defined names for the 'bag' in SOAPContext
  +  public static String BAG_HTTPSERVLET = "HttpServlet" ;
  +  public static String BAG_HTTPSESSION = "HttpSession" ;
  +  public static String BAG_HTTPSERVLETREQUEST = "HttpServletRequest" ;
  +  public static String BAG_HTTPSERVLETRESPONSE = "HttpServletResponse" ;
  +
   }
  
  
  
  1.2       +33 -27    xml-soap/java/src/org/apache/soap/providers/EntityEJBProvider.java
  
  Index: EntityEJBProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/providers/EntityEJBProvider.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EntityEJBProvider.java	2000/11/29 13:35:52	1.1
  +++ EntityEJBProvider.java	2001/01/16 14:26:40	1.2
  @@ -25,10 +25,16 @@
     /**
      * locate method comment.
      */
  -  public void locate(DeploymentDescriptor depDesc, Call origCall, 
  -                     String targetObjectURI, HttpServlet servletRef, 
  -                     HttpSession sessObj) throws SOAPException {
  -  
  +  public void locate(DeploymentDescriptor depDesc, 
  +                     Envelope env,
  +                     Call origCall, 
  +                     String methodName,
  +                     String targetObjectURI, 
  +                     SOAPContext reqContext) throws SOAPException {
  +
  +    HttpServlet servletRef = (HttpServlet) reqContext.getProperty( Constants.BAG_HTTPSERVLET );
  +    HttpSession sessObj    = (HttpSession) reqContext.getProperty( Constants.BAG_HTTPSESSION );
  +
       setDd(depDesc);
       setCall(origCall);
       setTargetObjectURI(origCall.getTargetObjectURI()) ;
  @@ -36,54 +42,54 @@
       setSession(sessObj);
       setMethodName(origCall.getMethodName());
       setMethodParameters(origCall.getParams());
  -  
  +
       // Check if there is a key appended to the URI;
       String fullURI = origCall.getFullTargetObjectURI();
       ejbKey = StatefulEJBProvider.getUniqueId(fullURI);
  -  
  +
       if (ejbKey != null) {
         setRemoteObjRef(deSerialize(ejbKey));
         // We have obtained the necessary object.
         return;
       }
  -  
  +
       Hashtable props = depDesc.getProps();
  -  
  +
       String ContxtProviderURL = (String) props.get("ContextProviderURL");
       String ContxtFactoryName = (String) props.get("FullContextFactoryName");
  -  
  +
       if ((ContxtProviderURL != null) && (ContxtFactoryName != null))
         initialize(ContxtProviderURL, ContxtFactoryName);
       else
         initialize(CNTXT_PROVIDER_URL, CNTXT_FACTORY_NAME);
  -  
  +
       String homeInterfaceName = (String) props.get("FullHomeInterfaceName");
       if (homeInterfaceName == null)
  -      throw new SOAPException(Constants.FAULT_CODE_SERVER, 
  +      throw new SOAPException(Constants.FAULT_CODE_SERVER,
                      "Error in Deployment Descriptor Property Settings");
  -  
  -    // From the Deployment Descriptor get the JNDI lookup name that is inside 
  +
  +    // From the Deployment Descriptor get the JNDI lookup name that is inside
       // the "java" element...
       String jndiName = depDesc.getProviderClass();
  -  
  +
       if ((jndiName != null) && (getContxt() != null)) {
         try {
           // Use service name to locate EJB home object via the contxt
           EJBHome home = (EJBHome) PortableRemoteObject.narrow(
  -                                   getContxt().lookup(jndiName), 
  +                                   getContxt().lookup(jndiName),
                                      Class.forName(homeInterfaceName));
  -  
  -        // Must check to see if the create method has any parameters associated 
  +
  +        // Must check to see if the create method has any parameters associated
           // with it.
           // There are 2 scenarios:
  -        //   1) if the method name in the call is create or find, then it will 
  +        //   1) if the method name in the call is create or find, then it will
           //      have parameters.
  -        //   2) if the method name in the call is not create or find, and 
  -        //      because no key is associated with this call, then we assume 
  -        //      that we can call create without any additional parameters, 
  +        //   2) if the method name in the call is not create or find, and
  +        //      because no key is associated with this call, then we assume
  +        //      that we can call create without any additional parameters,
           //      and prepare to invoke the given method.
  -  
  -        if ( getMethodName().equals("create") || 
  +
  +        if ( getMethodName().equals("create") ||
                getMethodName().startsWith("find") ) {
             // The method is create, so let the invoke method deal with it;
             //  just give it the home interface.
  @@ -91,12 +97,12 @@
             isCreate = true;
             return;
           } else {
  -          // Method name is something other than create or find - so, the 
  -          // invoke command has another directive to process; we just perform 
  +          // Method name is something other than create or find - so, the
  +          // invoke command has another directive to process; we just perform
             //  a basic 'create' then.
  -          Method createMethod = home.getClass().getMethod("create", 
  +          Method createMethod = home.getClass().getMethod("create",
                                                             new Class[0]);
  -          setRemoteObjRef((EJBObject) createMethod.invoke((Object) home, 
  +          setRemoteObjRef((EJBObject) createMethod.invoke((Object) home,
                                                             new Object[0]));
           }
         } catch (Exception e) {
  
  
  
  1.3       +52 -35    xml-soap/java/src/org/apache/soap/providers/StatefulEJBProvider.java
  
  Index: StatefulEJBProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/providers/StatefulEJBProvider.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StatefulEJBProvider.java	2001/01/08 16:58:07	1.2
  +++ StatefulEJBProvider.java	2001/01/16 14:26:40	1.3
  @@ -19,13 +19,14 @@
   
   public class StatefulEJBProvider implements Provider {
     public static String CNTXT_PROVIDER_URL = "iiop://localhost:900";
  -  public static String CNTXT_FACTORY_NAME = 
  +  public static String CNTXT_FACTORY_NAME =
                             "com.ibm.ejs.ns.jndi.CNInitialContextFactory";
     protected boolean isCreate = false;
     protected String ejbKey = null;
     public static String DELIM_CHAR = "@";
   
     private DeploymentDescriptor dd ;
  +  private Envelope             envelope ;
     private Call                 call ;
     private String               targetObjectURI ;
     private HttpServlet          servlet ;
  @@ -56,7 +57,7 @@
         throw new SOAPException(Constants.FAULT_CODE_SERVER, e.toString()) ;
       }
     }
  -  
  +
     public Call getCall() {
       return call;
     }
  @@ -112,13 +113,14 @@
           contxt = new InitialContext(properties);
         } catch (NamingException ne) {
           // ErrorListener?
  -        throw new SOAPException(Constants.FAULT_CODE_SERVER,  
  +        throw new SOAPException(Constants.FAULT_CODE_SERVER,
                                   "Unable to initialize context");
         }
       }
     }
   
  -  public Response invoke() throws SOAPException {
  +  public void invoke(SOAPContext reqContext, SOAPContext resContext)
  +                      throws SOAPException {
       Parameter ret = null;
       Object[] args = null;
       Class[] argTypes = null;
  @@ -145,7 +147,7 @@
   
       try {
         Method m = MethodUtils.getMethod (remoteObjRef, methodName, argTypes);
  -      Bean result = new Bean (m.getReturnType (), 
  +      Bean result = new Bean (m.getReturnType (),
                                 m.invoke (remoteObjRef, args));
   
         if (result.type != void.class) {
  @@ -164,7 +166,7 @@
       if (isCreate) {
         // The return parameter is an EJBObject (for a create method)
         //  or an Enumeration (for a find method)
  -      // IF this is an enumeration, we are only going to return the first 
  +      // IF this is an enumeration, we are only going to return the first
         // element
         try{
           remoteObjRef = (Remote) ret.getValue();
  @@ -173,7 +175,7 @@
           Enumeration enum = (Enumeration) ret.getValue();
           remoteObjRef = (Remote) enum.nextElement();
         }
  -      // Set the return value to null, so that the remote object is not 
  +      // Set the return value to null, so that the remote object is not
         // included in the response destined for the client.
         ret = null;
       }
  @@ -181,26 +183,41 @@
       if (ejbKey == null) {
         serialize();
       }
  +
  +    try {
  +      Response res = new Response( targetObjectURI,            // URI
  +                                   call.getMethodName(),       // Method
  +                                   (Parameter) ret,            // ReturnValue
  +                                   null,                       // Params
  +                                   null,                       // Header
  +                                   call.getEncodingStyleURI (),// encoding
  +                                   resContext );        // response soapcontext - not supported yet
  +      res.setFullTargetObjectURI(targetObjectURI +
  +                                 StatefulEJBProvider.DELIM_CHAR + ejbKey);
  +      Envelope env = res.buildEnvelope();
  +      StringWriter  sw = new StringWriter();
  +      env.marshall( sw, call.getSOAPMappingRegistry(), resContext );
  +      resContext.setRootPart( sw.toString(), Constants.HEADERVAL_CONTENT_TYPE_UTF8);
  +    }
  +    catch( Exception e ) {
  +      if ( e instanceof SOAPException ) throw (SOAPException ) e ;
  +      throw new SOAPException( Constants.FAULT_CODE_SERVER, e.toString() );
  +    }
  +  }
   
  -    Response res = new Response( targetObjectURI,            // URI
  -                                 call.getMethodName(),       // Method
  -                                 (Parameter) ret,            // ReturnValue
  -                                 null,                       // Params
  -                                 null,                       // Header
  -                                 call.getEncodingStyleURI (),// encoding
  -                                 new SOAPContext() );        // response soapcontext - not supported yet
  -
  -    res.setFullTargetObjectURI(targetObjectURI + 
  -                               StatefulEJBProvider.DELIM_CHAR + ejbKey);
  -    return res;
  -  }
  -
  -  public void locate(DeploymentDescriptor depDesc, Call origCall, 
  -                     String targURI, HttpServlet servletRef, 
  -                     HttpSession sessObj) 
  +  public void locate(DeploymentDescriptor depDesc, 
  +                     Envelope env,
  +                     Call origCall, 
  +                     String methodName ,
  +                     String targURI, 
  +                     SOAPContext reqContext)
                 throws SOAPException {
  +   
  +    HttpServlet servletRef = (HttpServlet) reqContext.getProperty( Constants.BAG_HTTPSERVLET );
  +    HttpSession sessObj    = (HttpSession) reqContext.getProperty( Constants.BAG_HTTPSESSION );
   
       dd              = depDesc ;
  +    envelope        = env ;
       call            = origCall ;
       targetObjectURI = origCall.getTargetObjectURI() ;
       servlet         = servletRef ;
  @@ -233,7 +250,7 @@
       if (homeInterfaceName == null)
         throw new SOAPException(Constants.FAULT_CODE_SERVER, "Error in Deployment Descriptor Property Settings");
   
  -    // From the Deployment Descriptor get the JNDI lookup name that is inside 
  +    // From the Deployment Descriptor get the JNDI lookup name that is inside
       // the "java" element...
       String jndiName = dd.getProviderClass();
   
  @@ -241,18 +258,18 @@
         try {
           // Use service name to locate EJB home object via the contxt
           EJBHome home = (EJBHome) PortableRemoteObject.narrow(
  -                                     contxt.lookup(jndiName), 
  +                                     contxt.lookup(jndiName),
                                        Class.forName(homeInterfaceName));
   
  -        // Must check to see if the create method has any parameters associated 
  +        // Must check to see if the create method has any parameters associated
           // with it.
           // There are 2 scenarios:
  -        //              1) if the method name in the call is create, then it 
  +        //              1) if the method name in the call is create, then it
           //                 will have parameters.
  -        //              2) if the method name in the call is not create, and 
  -        //                 because no key is associated with this call, then 
  -        //                 we assume that we can call create without any 
  -        //                 additional parameters, and prepare to invoke the 
  +        //              2) if the method name in the call is not create, and
  +        //                 because no key is associated with this call, then
  +        //                 we assume that we can call create without any
  +        //                 additional parameters, and prepare to invoke the
           //                 given method.
   
           if (methodName.equals("create")) {
  @@ -263,12 +280,12 @@
             return;
           }
   
  -        // Method name is something other than create - so, the invoke command 
  -        // has another directive to process; we just perform a basic 'create' 
  +        // Method name is something other than create - so, the invoke command
  +        // has another directive to process; we just perform a basic 'create'
           // then.
  -        Method createMethod = home.getClass().getMethod("create", 
  +        Method createMethod = home.getClass().getMethod("create",
                                                           new Class[0]);
  -        remoteObjRef = (EJBObject) createMethod.invoke((Object) home, 
  +        remoteObjRef = (EJBObject) createMethod.invoke((Object) home,
                                                          new Object[0]);
   
         } catch (Exception e) {
  
  
  
  1.3       +174 -153  xml-soap/java/src/org/apache/soap/providers/StatelessEJBProvider.java
  
  Index: StatelessEJBProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/providers/StatelessEJBProvider.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StatelessEJBProvider.java	2001/01/08 16:58:09	1.2
  +++ StatelessEJBProvider.java	2001/01/16 14:26:40	1.3
  @@ -74,188 +74,209 @@
   
   public class StatelessEJBProvider implements org.apache.soap.util.Provider {
   
  -	private DeploymentDescriptor dd ;
  -	private Call                 call ;
  -	private String               targetObjectURI ;
  -	private HttpServlet          servlet ;
  -	private HttpSession          session ;
  -
  -	private javax.naming.Context contxt = null;
  -	private EJBObject remoteObjRef = null;
  -	public static java.lang.String CNTXT_PROVIDER_URL = "iiop://localhost:900";
  -	public static java.lang.String CNTXT_FACTORY_NAME = "com.ibm.ejs.ns.jndi.CNInitialContextFactory";
  -	private java.lang.String methodName = null;
  -	private Vector methodParameters = null;
  -	private String respEncStyle = null;	
  +        private DeploymentDescriptor dd ;
  +        private Envelope             envelope ;
  +        private Call                 call ;
  +        private String               methodName ;
  +        private String               targetObjectURI ;
  +        private HttpServlet          servlet ;
  +        private HttpSession          session ;
  +
  +        private javax.naming.Context contxt = null;
  +        private EJBObject remoteObjRef = null;
  +        public static java.lang.String CNTXT_PROVIDER_URL = "iiop://localhost:900";
  +        public static java.lang.String CNTXT_FACTORY_NAME = "com.ibm.ejs.ns.jndi.CNInitialContextFactory";
  +        private Vector methodParameters = null;
  +        private String respEncStyle = null;
   /**
    * StatelessEJBProvider constructor comment.
    */
   public StatelessEJBProvider() {
  -	super();
  +        super();
   }
   
   private void initialize() throws SOAPException {
   
  -	if(contxt == null) {
  -			
  -		java.util.Properties properties = new java.util.Properties(); 
  -		properties.put(javax.naming.Context.PROVIDER_URL, CNTXT_PROVIDER_URL);
  -		properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, CNTXT_FACTORY_NAME);
  -		try {
  -			contxt = new javax.naming.InitialContext(properties);
  -		} catch (NamingException ne) {
  -			// ErrorListener?
  -			System.out.println("Naming Exception caught during InitialContext creation @ " + CNTXT_PROVIDER_URL);
  -			throw new SOAPException(Constants.FAULT_CODE_SERVER, "Unable to initialize context" );		
  -		}
  -	}
  -		
  +        if(contxt == null) {
  +
  +                java.util.Properties properties = new java.util.Properties();
  +                properties.put(javax.naming.Context.PROVIDER_URL, CNTXT_PROVIDER_URL);
  +                properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, CNTXT_FACTORY_NAME);
  +                try {
  +                        contxt = new javax.naming.InitialContext(properties);
  +                } catch (NamingException ne) {
  +                        // ErrorListener?
  +                        System.out.println("Naming Exception caught during InitialContext creation @ " + CNTXT_PROVIDER_URL);
  +                        throw new SOAPException(Constants.FAULT_CODE_SERVER, "Unable to initialize context" );
  +                }
  +        }
  +
   }
   
   private void initialize(String url, String factory) throws SOAPException {
  +
  +        if(contxt == null) {
  +
  +                java.util.Properties properties = new java.util.Properties();
   
  -	if(contxt == null) {
  -			
  -		java.util.Properties properties = new java.util.Properties();
  -
  -		properties.put(javax.naming.Context.PROVIDER_URL, url);
  -		properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, factory);
  -
  -		try {
  -			contxt = new javax.naming.InitialContext(properties);
  -		} catch (NamingException ne) {
  -			// ErrorListener?
  -			System.out.println("Naming Exception caught during InitialContext creation @ " + CNTXT_PROVIDER_URL);
  -			throw new SOAPException(Constants.FAULT_CODE_SERVER, "Unable to initialize context");		
  -		}
  -	}
  -		
  +                properties.put(javax.naming.Context.PROVIDER_URL, url);
  +                properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, factory);
  +
  +                try {
  +                        contxt = new javax.naming.InitialContext(properties);
  +                } catch (NamingException ne) {
  +                        // ErrorListener?
  +                        System.out.println("Naming Exception caught during InitialContext creation @ " + CNTXT_PROVIDER_URL);
  +                        throw new SOAPException(Constants.FAULT_CODE_SERVER, "Unable to initialize context");
  +                }
  +        }
  +
   }
   
   
   /**
    * invoke method comment.
    */
  -public org.apache.soap.rpc.Response invoke() throws org.apache.soap.SOAPException {
  -		  System.err.println( "=============================================" );
  -	  System.err.println("In TemplateProvider.invoke()" );
  -
  -	Parameter ret = null; 
  -	Object[] args = null;
  -	Class[] argTypes = null;
  -	if (methodParameters != null) {
  -		int parametersCount = methodParameters.size ();
  -		args = new Object[parametersCount];
  -		argTypes = new Class[parametersCount];
  -		
  -		for (int i = 0; i < parametersCount; i++) {
  -			Parameter param = (Parameter) methodParameters.elementAt (i);
  -			args[i] = param.getValue ();
  -			argTypes[i] = param.getType ();
  -			
  -			if (respEncStyle == null) {
  -				respEncStyle = param.getEncodingStyleURI ();
  -			}
  -	  	}
  -	}
  -	
  -	if (respEncStyle == null) {
  -	  respEncStyle = Constants.NS_URI_SOAP_ENC;
  -	}
  -
  -	try {
  -
  -		Method m = MethodUtils.getMethod (remoteObjRef, methodName, argTypes);
  -		Bean result = new Bean (m.getReturnType (), m.invoke (remoteObjRef, args));
  -		
  -
  -		if (result.type != void.class) {
  -		  ret = new Parameter (RPCConstants.ELEM_RETURN, result.type, 
  -						   result.value, null);
  -		}
  -
  -
  -	} catch (InvocationTargetException e) {
  -		System.err.println("Exception Caught upon method invocation attempt: " + e.getMessage());
  -		Throwable t = e.getTargetException ();
  -	  throw new SOAPException (Constants.FAULT_CODE_SERVER, t.getMessage(), t);
  -	}
  -	 catch (Throwable t) {
  -		System.err.println("Exception Caught upon method invocation attempt: " + t.toString());
  -		throw new SOAPException (Constants.FAULT_CODE_SERVER, t.getMessage(), t);
  -	}
  -		
  +public void invoke(SOAPContext reqContext, SOAPContext resContext)
  +                    throws SOAPException {
  +                  System.err.println( "=============================================" );
  +          System.err.println("In TemplateProvider.invoke()" );
  +
  +        Parameter ret = null;
  +        Object[] args = null;
  +        Class[] argTypes = null;
  +        if (methodParameters != null) {
  +                int parametersCount = methodParameters.size ();
  +                args = new Object[parametersCount];
  +                argTypes = new Class[parametersCount];
  +
  +                for (int i = 0; i < parametersCount; i++) {
  +                        Parameter param = (Parameter) methodParameters.elementAt (i);
  +                        args[i] = param.getValue ();
  +                        argTypes[i] = param.getType ();
  +
  +                        if (respEncStyle == null) {
  +                                respEncStyle = param.getEncodingStyleURI ();
  +                        }
  +                }
  +        }
  +
  +        if (respEncStyle == null) {
  +          respEncStyle = Constants.NS_URI_SOAP_ENC;
  +        }
  +
  +        try {
  +
  +                Method m = MethodUtils.getMethod (remoteObjRef, methodName, argTypes);
  +                Bean result = new Bean (m.getReturnType (), m.invoke (remoteObjRef, args));
  +
  +
  +                if (result.type != void.class) {
  +                  ret = new Parameter (RPCConstants.ELEM_RETURN, result.type,
  +                                                   result.value, null);
  +                }
  +
  +
  +        } catch (InvocationTargetException e) {
  +                System.err.println("Exception Caught upon method invocation attempt: " + e.getMessage());
  +                Throwable t = e.getTargetException ();
  +          throw new SOAPException (Constants.FAULT_CODE_SERVER, t.getMessage(), t);
  +        }
  +         catch (Throwable t) {
  +                System.err.println("Exception Caught upon method invocation attempt: " + t.toString());
  +                throw new SOAPException (Constants.FAULT_CODE_SERVER, t.getMessage(), t);
  +        }
   
  -	  return new Response( targetObjectURI,            // URI
  +        try {
  +          Response resp = new Response( targetObjectURI,            // URI
                                  call.getMethodName(),       // Method
                                  (Parameter) ret,            // ReturnValue
                                  null,                       // Params
                                  null,                       // Header
                                  call.getEncodingStyleURI (),// encoding
  -                               new SOAPContext() );        // response soapcontext - not supported yet
  +                               resContext );        // response soapcontext - not supported yet
  +                  Envelope env = resp.buildEnvelope();
  +                  StringWriter  sw = new StringWriter();
  +                  env.marshall( sw, call.getSOAPMappingRegistry(), resContext );
  +                  resContext.setRootPart( sw.toString(), Constants.HEADERVAL_CONTENT_TYPE_UTF8);
  +                }
  +                catch( Exception e ) {
  +                  if ( e instanceof SOAPException ) throw (SOAPException ) e ;
  +                  throw new SOAPException( Constants.FAULT_CODE_SERVER, e.toString() );
  +                }
   }
   
   /**
    * locate method comment.
    */
  -public void locate(org.apache.soap.server.DeploymentDescriptor dd, org.apache.soap.rpc.Call call, String targetObjectURI, javax.servlet.http.HttpServlet servlet, javax.servlet.http.HttpSession session) throws org.apache.soap.SOAPException {
  -	
  -
  -	  System.err.println( "=============================================" );
  -	  System.err.println( "In TemplateProvider.locate()" );
  -	  System.err.println( "URI: " + targetObjectURI );
  -	  System.err.println( "DD.ServiceClass: " + dd.getServiceClass() );
  -	  System.err.println( "DD.ProviderClass: " + dd.getProviderClass() );
  -	  System.err.println( "Call.MethodName: " + call.getMethodName() );
  -
  -	  this.dd              = dd ;
  -	  this.call            = call ;
  -	  this.targetObjectURI = targetObjectURI ;
  -	  this.servlet         = servlet ;
  -	  this.session         = session ;
  -
  -	  Hashtable props = dd.getProps();
  -
  -	
  -	String ContxtProviderURL = (String) props.get("ContextProviderURL");
  -	String ContxtFactoryName = (String) props.get("FullContextFactoryName");
  -	
  -	if ((ContxtProviderURL != null) && (ContxtFactoryName != null))
  -		initialize(ContxtProviderURL, ContxtFactoryName);
  -	else
  -		initialize();
  -		
  -	String homeInterfaceName = (String) props.get("FullHomeInterfaceName");
  -	if (homeInterfaceName == null) 
  -		throw new SOAPException(Constants.FAULT_CODE_SERVER, "Error in Deployment Descriptor Property Settings");		
  -			
  -	// From the Deployment Descriptor get the JNDI lookup name that is inside the "java" element...
  -	String jndiName = dd.getProviderClass();
  -	
  -
  -	if ((jndiName != null) && (contxt != null)) {
  -
  -		try {
  -
  -			// Use service name to locate EJB home object via the contxt
  -			// EJBHome home = (EJBHome) contxt.lookup(jndiName);
  -			EJBHome home = (EJBHome) PortableRemoteObject.narrow(contxt.lookup(jndiName), Class.forName(homeInterfaceName));
  -			// call the 'create' method on the EJB home object, and store the
  -			//   ref to the EJB object.
  -			Method createMethod = home.getClass().getMethod("create", new Class[0]);
  -			remoteObjRef = (EJBObject) createMethod.invoke((Object) home, new Object[0]);
  -
  -		} catch (Exception e) {
  -
  -			System.out.println("Exception caught: " + e.toString());
  -			throw new SOAPException(Constants.FAULT_CODE_SERVER,"Error in connecting to EJB", e);
  -		}
  -	}
  -
  -	// Once previous steps have been successful, then we take the Call Object
  -	//  and extract the method name from it, and any parameters, and store them.
  -	methodName = call.getMethodName();
  -	methodParameters = call.getParams();
  +public void locate(DeploymentDescriptor dd, 
  +                   Envelope env, 
  +                   Call call, 
  +                   String methodName, 
  +                   String targetObjectURI, 
  +                   SOAPContext reqContext)
  +              throws org.apache.soap.SOAPException {
  +
  +          HttpServlet servlet = (HttpServlet) reqContext.getProperty( Constants.BAG_HTTPSERVLET );
  +          HttpSession session = (HttpSession) reqContext.getProperty( Constants.BAG_HTTPSESSION );
  +
  +          System.err.println( "=============================================" );
  +          System.err.println( "In TemplateProvider.locate()" );
  +          System.err.println( "URI: " + targetObjectURI );
  +          System.err.println( "DD.ServiceClass: " + dd.getServiceClass() );
  +          System.err.println( "DD.ProviderClass: " + dd.getProviderClass() );
  +          System.err.println( "Call.MethodName: " + call.getMethodName() );
  +
  +          this.dd              = dd ;
  +          this.envelope        = env ;
  +          this.call            = call ;
  +          this.methodName      = methodName ;
  +          this.targetObjectURI = targetObjectURI ;
  +          this.servlet         = servlet ;
  +          this.session         = session ;
  +
  +          Hashtable props = dd.getProps();
  +
  +
  +        String ContxtProviderURL = (String) props.get("ContextProviderURL");
  +        String ContxtFactoryName = (String) props.get("FullContextFactoryName");
  +
  +        if ((ContxtProviderURL != null) && (ContxtFactoryName != null))
  +                initialize(ContxtProviderURL, ContxtFactoryName);
  +        else
  +                initialize();
  +
  +        String homeInterfaceName = (String) props.get("FullHomeInterfaceName");
  +        if (homeInterfaceName == null)
  +                throw new SOAPException(Constants.FAULT_CODE_SERVER, "Error in Deployment Descriptor Property Settings");
  +
  +        // From the Deployment Descriptor get the JNDI lookup name that is inside the "java" element...
  +        String jndiName = dd.getProviderClass();
  +
  +
  +        if ((jndiName != null) && (contxt != null)) {
  +
  +                try {
  +
  +                        // Use service name to locate EJB home object via the contxt
  +                        // EJBHome home = (EJBHome) contxt.lookup(jndiName);
  +                        EJBHome home = (EJBHome) PortableRemoteObject.narrow(contxt.lookup(jndiName), Class.forName(homeInterfaceName));
  +                        // call the 'create' method on the EJB home object, and store the
  +                        //   ref to the EJB object.
  +                        Method createMethod = home.getClass().getMethod("create", new Class[0]);
  +                        remoteObjRef = (EJBObject) createMethod.invoke((Object) home, new Object[0]);
  +
  +                } catch (Exception e) {
  +
  +                        System.out.println("Exception caught: " + e.toString());
  +                        throw new SOAPException(Constants.FAULT_CODE_SERVER,"Error in connecting to EJB", e);
  +                }
  +        }
  +
  +        // Once previous steps have been successful, then we take the Call Object
  +        //  and extract the method name from it, and any parameters, and store them.
  +        methodName = call.getMethodName();
  +        methodParameters = call.getParams();
   
   
   }
  
  
  
  1.4       +32 -11    xml-soap/java/src/org/apache/soap/providers/TemplateProvider.java
  
  Index: TemplateProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/providers/TemplateProvider.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TemplateProvider.java	2001/01/08 16:58:10	1.3
  +++ TemplateProvider.java	2001/01/16 14:26:40	1.4
  @@ -68,19 +68,27 @@
   
   public class TemplateProvider implements Provider {
       private DeploymentDescriptor dd ;
  +    private Envelope             envelope ;
       private Call                 call ;
  +    private String               methodName ;
       private String               targetObjectURI ;
       private HttpServlet          servlet ;
       private HttpSession          session ;
   
       public void locate( DeploymentDescriptor dd,
  +                        Envelope env,
                           Call call,
  +                        String methodName,
                           String targetObjectURI,
  -                        HttpServlet servlet,
  -                        HttpSession session)
  +                        SOAPContext reqContext)
           throws SOAPException {
  +
  +      HttpServlet servlet = (HttpServlet) reqContext.getProperty( Constants.BAG_HTTPSERVLET );
  +      HttpSession session = (HttpSession) reqContext.getProperty( Constants.BAG_HTTPSESSION );
  +
         System.err.println( "=============================================" );
         System.err.println( "In TemplateProvider.locate()" );
  +      System.err.println( "Method: " + methodName );
         System.err.println( "URI: " + targetObjectURI );
         System.err.println( "DD.ServiceClass: " + dd.getServiceClass() );
         System.err.println( "DD.ProviderClass: " + dd.getProviderClass() );
  @@ -97,7 +105,9 @@
         }
   
         this.dd              = dd ;
  +      this.envelope        = env ;
         this.call            = call ;
  +      this.methodName      = methodName ;
         this.targetObjectURI = targetObjectURI ;
         this.servlet         = servlet ;
         this.session         = session ;
  @@ -106,7 +116,8 @@
       };
   
   
  -    public Response invoke() throws SOAPException {
  +    public void invoke(SOAPContext reqContext, SOAPContext resContext)
  +                        throws SOAPException {
         System.err.println( "=============================================" );
         System.err.println( "In TemplateProvider.invoke()" );
   
  @@ -115,13 +126,23 @@
         // If you want the client to use a new targetObjectURI for subsequence
         // calls place it here (targetObjectURI on 'new Response').
         //   i.e. we added an 'instance-id' to the urn
  -
  -      return new Response( targetObjectURI,            // URI
  -                           call.getMethodName(),       // Method
  -                           (Parameter) null,           // ReturnValue
  -                           null,                       // Params
  -                           null,                       // Header
  -                           null,                       // encoding
  -                           new SOAPContext() );        // response soapcontext - not supported yet
  +      try {
  +            Response resp = new Response( targetObjectURI,   // URI
  +                             call.getMethodName(),  // Method
  +                             (Parameter) null,      // ReturnValue
  +                             null,                  // Params
  +                             null,                  // Header
  +                             null,                  // encoding
  +                             resContext );          // response soapcontext - not supported yet
  +
  +            Envelope env = resp.buildEnvelope();
  +            StringWriter  sw = new StringWriter();
  +            env.marshall( sw, call.getSOAPMappingRegistry(), resContext );
  +            resContext.setRootPart( sw.toString(), Constants.HEADERVAL_CONTENT_TYPE_UTF8);
  +      }
  +      catch( Exception e ) {
  +        if ( e instanceof SOAPException ) throw (SOAPException ) e ;
  +        throw new SOAPException( Constants.FAULT_CODE_SERVER, e.toString() );
  +      }
       };
   };
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/providers/MsgJavaProvider.java
  
  Index: MsgJavaProvider.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "SOAP" 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 apache@apache.org.
   *
   * 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 and was
   * originally based on software copyright (c) 2000, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.soap.providers ;
  
  import java.io.* ;
  import javax.servlet.* ;
  import javax.servlet.http.* ;
  import org.apache.soap.* ;
  import org.apache.soap.rpc.* ;
  import org.apache.soap.server.* ;
  import org.apache.soap.server.http.* ;
  import org.apache.soap.util.* ;
  
  public class MsgJavaProvider implements Provider {
      private DeploymentDescriptor dd ;
      private Envelope             envelope ;
      private Call                 call ;
      private String               methodName ;
      private String               targetObjectURI ;
      private HttpServlet          servlet ;
      private HttpSession          session ;
  
      private Object               targetObject ;
  
      public void locate( DeploymentDescriptor dd,
                          Envelope env,
                          Call call,
                          String methodName,
                          String targetObjectURI,
                          SOAPContext reqContext)
          throws SOAPException {
  
        HttpServlet servlet = (HttpServlet) reqContext.getProperty( Constants.BAG_HTTPSERVLET );
        HttpSession session = (HttpSession) reqContext.getProperty( Constants.BAG_HTTPSESSION );
  
        this.dd              = dd ;
        this.envelope        = env ;
        this.call            = call ;
        this.methodName      = methodName ;
        this.targetObjectURI = targetObjectURI ;
        this.servlet         = servlet ;
        this.session         = session ;
  
        ServletConfig  config  = servlet.getServletConfig();
        ServletContext context = config.getServletContext ();
        ServiceManager serviceManager =
          ServerHTTPUtils.getServiceManagerFromContext (context);
  
        // Default processing for 'java' and 'script' providers
        // call on a valid method name?
        if (!MessageRouter.validMessage (dd, methodName)) {
          throw new SOAPException (Constants.FAULT_CODE_SERVER,
                                   "Method '" + methodName +
                                   "' is not supported.");
        }
  
        // get at the target object
        targetObject = ServerHTTPUtils.getTargetObject(serviceManager,
                                                       dd, targetObjectURI,
                                                       servlet, session,
                                                       context);
      };
  
  
      public void invoke(SOAPContext reqContext, SOAPContext resContext)
                 throws SOAPException {
        // invoke the method on the target object
        try {
          MessageRouter.invoke( dd, envelope, targetObject,
                                methodName, reqContext, resContext );
        }
        catch( Exception e ) {
          if ( e instanceof SOAPException ) throw (SOAPException ) e ;
          e.printStackTrace( System.err) ;
          throw new SOAPException( Constants.FAULT_CODE_SERVER, e.toString() );
        }
      };
  };
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/providers/RPCJavaProvider.java
  
  Index: RPCJavaProvider.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "SOAP" 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 apache@apache.org.
   *
   * 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 and was
   * originally based on software copyright (c) 2000, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.soap.providers ;
  
  import java.io.* ;
  import javax.servlet.* ;
  import javax.servlet.http.* ;
  import org.apache.soap.* ;
  import org.apache.soap.rpc.* ;
  import org.apache.soap.server.* ;
  import org.apache.soap.server.http.* ;
  import org.apache.soap.util.* ;
  
  public class RPCJavaProvider implements Provider {
      private DeploymentDescriptor dd ;
      private Envelope             envelope ;
      private Call                 call ;
      private String               methodName ;
      private String               targetObjectURI ;
      private HttpServlet          servlet ;
      private HttpSession          session ;
  
      private Object               targetObject ;
  
      public void locate( DeploymentDescriptor dd,
                          Envelope env,
                          Call call,
                          String methodName,
                          String targetObjectURI,
                          SOAPContext reqContext )
          throws SOAPException {
        
        HttpServlet servlet = (HttpServlet) reqContext.getProperty( Constants.BAG_HTTPSERVLET );
        HttpSession session = (HttpSession) reqContext.getProperty( Constants.BAG_HTTPSESSION );
  
        this.dd              = dd ;
        this.envelope        = env ;
        this.call            = call ;
        this.methodName      = methodName ;
        this.targetObjectURI = targetObjectURI ;
        this.servlet         = servlet ;
        this.session         = session ;
  
        ServletConfig  config  = servlet.getServletConfig();
        ServletContext context = config.getServletContext ();
        ServiceManager serviceManager =
          ServerHTTPUtils.getServiceManagerFromContext (context);
  
        // Default processing for 'java' and 'script' providers
        // call on a valid method name?
        if (!RPCRouter.validCall (dd, call)) {
          throw new SOAPException (Constants.FAULT_CODE_SERVER,
                                   "Method '" + call.getMethodName () +
                                   "' is not supported.");
        }
  
        // get at the target object
        targetObject = ServerHTTPUtils.getTargetObject (serviceManager,
                                                        dd, targetObjectURI,
                                                        servlet, session,
                                                        context);
      };
  
  
      public void invoke(SOAPContext reqContext, SOAPContext resContext)
                 throws SOAPException {
        // invoke the method on the target object
        try {
          Response resp = RPCRouter.invoke( dd, call, targetObject, resContext );
          Envelope env = resp.buildEnvelope();
          StringWriter  sw = new StringWriter();
          env.marshall( sw, call.getSOAPMappingRegistry(), resContext );
          resContext.setRootPart( sw.toString(), Constants.HEADERVAL_CONTENT_TYPE_UTF8);
        }
        catch( Exception e ) {
          if ( e instanceof SOAPException ) throw (SOAPException ) e ;
          throw new SOAPException( Constants.FAULT_CODE_SERVER, e.toString() );
        }
      };
  };
  
  
  
  1.4       +29 -0     xml-soap/java/src/org/apache/soap/rpc/SOAPContext.java
  
  Index: SOAPContext.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/rpc/SOAPContext.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SOAPContext.java	2001/01/16 14:17:19	1.3
  +++ SOAPContext.java	2001/01/16 14:26:41	1.4
  @@ -78,6 +78,7 @@
    */
   public class SOAPContext {
       protected MimeMultipart parts;
  +    protected Hashtable     bag  = new Hashtable();
   
       /**
        * This flag indicates if setRootPart() was called, so we can distinguish
  @@ -511,6 +512,34 @@
               msg.saveChanges();
               msg.writeTo(os, ignoreHeaders);
           }
  +    }
  +
  +    /**
  +     * Store something in the hold-all 'bag'
  +     */
  +    public void setProperty(String name, Object value) {
  +      bag.put( name, value );
  +    }
  +
  +    /**
  +     * Look for something in the hold-all 'bag'
  +     */
  +    public Object getProperty(String name) {
  +      return( bag.get(name) );
  +    }
  +
  +    /**
  +     * Remove something from the hold-all 'bag'
  +     */
  +    public Object removeProperty(String name) {
  +      return( bag.remove(name) );
  +    }
  +
  +    /**
  +     * Return the entire list of 'names' in the hold-all 'bag'
  +     */
  +    public Enumeration getPropertyNames() {
  +      return( bag.keys() );
       }
   
       /**
  
  
  
  1.4       +7 -9      xml-soap/java/src/org/apache/soap/server/MessageRouter.java
  
  Index: MessageRouter.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/MessageRouter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MessageRouter.java	2001/01/08 12:25:20	1.3
  +++ MessageRouter.java	2001/01/16 14:26:41	1.4
  @@ -36,24 +36,24 @@
      * Deliver the message to the appropriate method on the given target
      * object.
      */
  -  public static SOAPContext invoke (DeploymentDescriptor dd, Envelope env,
  -                                    Object targetObject, String messageName,
  -                                    SOAPContext reqCtx)
  +
  +  public static void invoke (DeploymentDescriptor dd, Envelope env,
  +                             Object targetObject, String messageName,
  +                             SOAPContext reqCtx, SOAPContext resCtx)
          throws SOAPException {
       byte providerType = dd.getProviderType ();
   
       try {
         // Class[] argTypes = new Class[] { Envelope.class, PrintWriter.class };
         // Object[] args = new Object[] { env, out };
  -      Class[] argTypes = new Class[] { Envelope.class, SOAPContext.class };
  -      Object[] args = new Object[] { env, reqCtx };
  +      Class[] argTypes = new Class[] { Envelope.class, SOAPContext.class,
  +                                                       SOAPContext.class };
  +      Object[] args = new Object[] { env, reqCtx, resCtx };
   
  -      SOAPContext resCtx;
         if (providerType == DeploymentDescriptor.PROVIDER_JAVA) {
           Method m = MethodUtils.getMethod (targetObject, messageName,
                                             argTypes);
           Object resObj = m.invoke (targetObject, args);
  -        resCtx = (SOAPContext)resObj;
         } else {
           // find the class that provides the BSF services (done
           // this way via reflection to avoid a compile-time dependency on BSF)
  @@ -66,9 +66,7 @@
                          Object[].class};
           Method m = MethodUtils.getMethod (bc, "service", sig, true);
           m.invoke (null, new Object[] {dd, targetObject, messageName, args});
  -        resCtx = new SOAPContext();
         }
  -      return resCtx;
       } catch (InvocationTargetException e) {
         Throwable t = e.getTargetException ();
         throw new SOAPException (Constants.FAULT_CODE_SERVER, t.getMessage(), t);
  
  
  
  1.8       +2 -2      xml-soap/java/src/org/apache/soap/server/RPCRouter.java
  
  Index: RPCRouter.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/RPCRouter.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- RPCRouter.java	2001/01/08 12:25:20	1.7
  +++ RPCRouter.java	2001/01/16 14:26:41	1.8
  @@ -66,7 +66,8 @@
      * Do the call on the given target object.
      */
     public static Response invoke (DeploymentDescriptor dd,
  -                                 Call call, Object targetObject) 
  +                                 Call call, Object targetObject,
  +                                 SOAPContext ctx ) 
          throws SOAPException {
       byte providerType = dd.getProviderType ();
   
  @@ -96,7 +97,6 @@
       // invoke the method (directly for Java and via InvokeBSF for script
       // methods)
       Bean result = null;
  -    SOAPContext ctx = new SOAPContext();
       try {
         if (providerType == DeploymentDescriptor.PROVIDER_JAVA) {
           Method m = MethodUtils.getMethod (targetObject, call.getMethodName (),
  
  
  
  1.4       +2 -2      xml-soap/java/src/org/apache/soap/server/ServerUtils.java
  
  Index: ServerUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/ServerUtils.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ServerUtils.java	2001/01/08 12:25:21	1.3
  +++ ServerUtils.java	2001/01/16 14:26:41	1.4
  @@ -129,9 +129,9 @@
               return null;
   
           if ("java" == className)
  -            className = "org.apache.soap.providers.JavaProvider";
  +            className = "org.apache.soap.providers.RPCJavaProvider";
           else if ("script" == className)
  -            className = "org.apache.soap.providers.JavaProvider";
  +            className = "org.apache.soap.providers.RPCJavaProvider";
   
           try {
               c = Class.forName (className);
  
  
  
  1.11      +26 -19    xml-soap/java/src/org/apache/soap/server/http/MessageRouterServlet.java
  
  Index: MessageRouterServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/http/MessageRouterServlet.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- MessageRouterServlet.java	2001/01/08 12:25:22	1.10
  +++ MessageRouterServlet.java	2001/01/16 14:26:41	1.11
  @@ -161,8 +161,8 @@
          throws ServletException, IOException {
       PrintWriter out = res.getWriter ();
   
  - 	res.setContentType("text/html");
  -	out.println("<html><head><title>SOAP RPC Router</title></head>");
  +        res.setContentType("text/html");
  +        out.println("<html><head><title>SOAP RPC Router</title></head>");
       out.println ("<body><h1>SOAP RPC Router</h1>");
       out.println ("<p>Sorry, I don't speak via HTTP GET- you have to use");
       out.println ("HTTP POST to talk to me.</p></body></html>");
  @@ -174,14 +174,15 @@
       ServletConfig config = getServletConfig();
       ServletContext context = config.getServletContext ();
       HttpSession session = req.getSession ();
  -    ServiceManager serviceManager = 
  +    ServiceManager serviceManager =
         ServerHTTPUtils.getServiceManagerFromContext (context);
       int status;
       DeploymentDescriptor dd = null;
       TransportMessage sres;
       try {
         // get the envelope and request SOAPContext
  -      SOAPContext reqCtx = new SOAPContext(), resCtx;
  +      SOAPContext reqCtx = new SOAPContext() ;
  +      SOAPContext resCtx = new SOAPContext() ;
   
         // Generate Envelope after the incoming message is translated by
         // EnvelopeEditor
  @@ -200,7 +201,7 @@
         // element of the body of the envelope
         Body body = msgEnv.getBody ();
         Element e = (Element) body.getBodyEntries().elementAt (0);
  -      if (e == null) { 
  +      if (e == null) {
           res.sendError (res.SC_BAD_REQUEST, "Element's body is empty!");
         }
         String targetID = e.getNamespaceURI ();
  @@ -208,22 +209,28 @@
   
         // is this a valid message?
         dd = serviceManager.query (targetID);
  -      if (!MessageRouter.validMessage (dd, messageName)) {
  -        throw new SOAPException (Constants.FAULT_CODE_SERVER,
  -                                 "Message '" + messageName + "' unknown to " +
  -                                 "service '" + targetID + "'");
  +
  +      Provider provider;
  +      if ( dd.getProviderType() == DeploymentDescriptor.PROVIDER_JAVA ) {
  +        // Handle Java based services
  +        provider = new org.apache.soap.providers.MsgJavaProvider();
  +      } else if (dd.getProviderType() ==
  +                 DeploymentDescriptor.PROVIDER_USER_DEFINED) {
  +        // Handle user-defined providers
  +        provider = ServerUtils.loadProvider(dd);
  +      } else {
  +        // Handle scripts
  +        provider = new org.apache.soap.providers.MsgJavaProvider();
         }
  +
  +      reqCtx.setProperty( Constants.BAG_HTTPSERVLET, this );
  +      reqCtx.setProperty( Constants.BAG_HTTPSESSION, session );
  +      reqCtx.setProperty( Constants.BAG_HTTPSERVLETREQUEST, req );
  +      reqCtx.setProperty( Constants.BAG_HTTPSERVLETRESPONSE, res );
  +
  +      provider.locate( dd, msgEnv, null, messageName, targetID, reqCtx );
  +      provider.invoke( reqCtx, resCtx );
   
  -      // get at the target object
  -      Object targetObject = ServerHTTPUtils.getTargetObject (serviceManager,
  -                                                             dd, targetID, 
  -                                                             this, session,
  -                                                             context);
  -
  -      // invoke the method on the target object and give it the output
  -      // stream to write to if needed
  -      resCtx = MessageRouter.invoke (dd, msgEnv, targetObject,
  -                                     messageName, reqCtx);
         sres = new TransportMessage(null,
                                     resCtx,
                                     null);
  
  
  
  1.14      +29 -21    xml-soap/java/src/org/apache/soap/server/http/RPCRouterServlet.java
  
  Index: RPCRouterServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/http/RPCRouterServlet.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- RPCRouterServlet.java	2001/01/08 12:25:23	1.13
  +++ RPCRouterServlet.java	2001/01/16 14:26:41	1.14
  @@ -87,7 +87,7 @@
    * @author Sanjiva Weerawarana <sa...@watson.ibm.com>
    * @author Matthew J. Duftler <du...@us.ibm.com>
    * @author Steven McDowall <sj...@aptest.com>
  - * @author Eric M. Dashofy (edashofy@ics.uci.edu) 
  + * @author Eric M. Dashofy (edashofy@ics.uci.edu)
    * @author Kevin J. Mitchell (kevin.mitchell@xmls.com)
    * @author Wouter Cloetens (wcloeten@raleigh.ibm.com)
    */
  @@ -158,7 +158,7 @@
         return null;
       }
       System.err.println(getClass().getName() +
  -                       " god a init parameter '" + name + "'=" + value);
  +                       " got a init parameter '" + name + "'=" + value);
       try {
         return Class.forName(value).newInstance();
       } catch (ClassNotFoundException e) {
  @@ -192,7 +192,7 @@
       ServletContext context = config.getServletContext ();
   
       HttpSession session = req.getSession ();
  -    ServiceManager serviceManager = 
  +    ServiceManager serviceManager =
         ServerHTTPUtils.getServiceManagerFromContext (context);
       Call call = null;
       Response resp = null;
  @@ -201,18 +201,21 @@
       int status = res.SC_OK;
       DeploymentDescriptor dd = null;
   
  +    SOAPContext reqCtx = new SOAPContext();
  +    SOAPContext resCtx = new SOAPContext();
  +    Envelope    callEnv = null ;
  +
       try {
         // extract the call
         try {
           // Carry the request context from the read to the creation of
           // the Call object.
  -        SOAPContext reqCtx = new SOAPContext();
   
           // Generate Envelope after the incoming message is translated by
           // EnvelopeEditor
           // Note: XMLParser that is specified by init-param isused in
           // this process.
  -        Envelope callEnv =
  +        callEnv =
             ServerHTTPUtils.readEnvelopeFromRequest(xpl,
                                                     req.getContentType(),
                                                     req.getContentLength(),
  @@ -242,18 +245,25 @@
         Provider provider;
         if ( dd.getProviderType() == DeploymentDescriptor.PROVIDER_JAVA ) {
           // Handle Java based services
  -        provider = new org.apache.soap.providers.JavaProvider();
  +        provider = new org.apache.soap.providers.RPCJavaProvider();
         } else if (dd.getProviderType() ==
                    DeploymentDescriptor.PROVIDER_USER_DEFINED) {
           // Handle user-defined providers
           provider = ServerUtils.loadProvider(dd);
         } else {
           // Handle scripts
  -        provider = new org.apache.soap.providers.JavaProvider();
  +        provider = new org.apache.soap.providers.RPCJavaProvider();
         }
  -      provider.locate( dd, call, fullTargetID, this, session );
  +      
  +      reqCtx.setProperty( Constants.BAG_HTTPSERVLET, this );
  +      reqCtx.setProperty( Constants.BAG_HTTPSESSION, session );
  +      reqCtx.setProperty( Constants.BAG_HTTPSERVLETREQUEST, req );
  +      reqCtx.setProperty( Constants.BAG_HTTPSERVLETRESPONSE, res );
  +
  +      provider.locate( dd, callEnv, call, call.getMethodName(), fullTargetID, 
  +                       reqCtx );
  +      provider.invoke( reqCtx, resCtx );
   
  -      resp = provider.invoke();
       } catch (Throwable t) {
         // note that we catch runtime errors too with the above .. the
         // idea is to do a SOAP fault for everything that goes out so
  @@ -261,7 +271,7 @@
         // get it. If not, it doesn't hurt.
         SOAPException e = null;
         if (t instanceof SOAPException)
  -        e = (SOAPException)	t;
  +        e = (SOAPException)     t;
         else
           e = new SOAPException(Constants.FAULT_CODE_SERVER +
                                 ".Exception:", "", t);
  @@ -275,7 +285,7 @@
         if (fault.getFaultCode().startsWith (Constants.FAULT_CODE_CLIENT)) {
           status = ServerConstants.SC_BAD_REQUEST;
         } else {
  -	status = res.SC_INTERNAL_SERVER_ERROR;
  +        status = res.SC_INTERNAL_SERVER_ERROR;
         }
   
         String respEncStyle = null;
  @@ -285,21 +295,19 @@
           respEncStyle = Constants.NS_URI_SOAP_ENC;
   
         resp = new Response (null, null, fault, null, null, respEncStyle);
  +      SOAPMappingRegistry smr = (call != null
  +                                 ? call.getSOAPMappingRegistry ()
  +                                 : new SOAPMappingRegistry());
  +      Envelope env = resp.buildEnvelope();
  +      StringWriter sw = new StringWriter();
  +      env.marshall(sw, smr, resp.getSOAPContext());
  +      String envelopeString = sw.toString();
       }
   
       try
       {
           // Generate response.
  -	SOAPMappingRegistry smr = (call != null
  -                                   ? call.getSOAPMappingRegistry ()
  -                                   : new SOAPMappingRegistry());
  -        Envelope env = resp.buildEnvelope();
  -        StringWriter sw = new StringWriter();
  -        env.marshall(sw, smr, resp.getSOAPContext());
  -        String envelopeString = sw.toString();
  -        TransportMessage sres = new TransportMessage(envelopeString,
  -                                                     resp.getSOAPContext(),
  -                                                     null);
  +        TransportMessage sres = new TransportMessage(null, resCtx, null );
           sres.editOutgoing(editor);
   
           // Generate response byte array.
  
  
  
  1.2       +9 -8      xml-soap/java/src/org/apache/soap/util/Provider.java
  
  Index: Provider.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/util/Provider.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Provider.java	2000/11/07 00:35:02	1.1
  +++ Provider.java	2001/01/16 14:26:41	1.2
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2000 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2000 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -10,7 +10,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    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
  @@ -18,7 +18,7 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:  
  + *    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,
  @@ -26,7 +26,7 @@
    *
    * 4. The names "SOAP" and "Apache Software Foundation" must
    *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -78,11 +78,12 @@
    */
   public interface Provider
   {
  -  public void locate( DeploymentDescriptor dd, 
  +  public void locate( DeploymentDescriptor dd,
  +                      Envelope             env,
                         Call                 call,
  +                      String               methodName,
                         String               targetObjectURI,
  -		      HttpServlet          servlet,
  -		      HttpSession          session )
  +                      SOAPContext          reqContext)
                   throws SOAPException ;
  -  public Response invoke( ) throws SOAPException ;
  +  public void invoke(SOAPContext req, SOAPContext res) throws SOAPException ;
   }