You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by du...@apache.org on 2001/09/04 18:10:53 UTC

cvs commit: xml-axis/java/src/org/apache/axis/providers/java MsgProvider.java

dug         01/09/04 09:10:53

  Modified:    java/src/org/apache/axis/providers/java MsgProvider.java
  Log:
  Make MSGDispatcher look for a service with just a Document as the
  param - if not there, then look for one with msgContext as the
  first arg.
  
  Revision  Changes    Path
  1.9       +27 -9     xml-axis/java/src/org/apache/axis/providers/java/MsgProvider.java
  
  Index: MsgProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/java/MsgProvider.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- MsgProvider.java	2001/08/29 14:17:17	1.8
  +++ MsgProvider.java	2001/09/04 16:10:53	1.9
  @@ -109,12 +109,11 @@
           
           // the document which is the contents of the first body element
           // (generated only if we are not an envelope service)
  -        Document doc;
  +        Method   method = null ;
  +        Document doc = null ;
           
           if (bodyOnlyService) {
               // dig out just the body, and pass it with the MessageContext
  -            argClasses = new Class[2];
  -            argObjects = new Object[2];
               SOAPBodyElement reqBody = reqEnv.getFirstBody();
               
               doc = reqBody.getAsDOM().getOwnerDocument();
  @@ -127,24 +126,43 @@
                   Element root = doc.getDocumentElement();
                   if ( root != null ) methodName = root.getLocalName();
               }
  -            argClasses[0] = msgContext.getClassLoader().loadClass("org.apache.axis.MessageContext");
  -            argClasses[1] = msgContext.getClassLoader().loadClass("org.w3c.dom.Document");
  -            argObjects[0] = msgContext ;
  -            argObjects[1] = doc ;
  +
  +            // Try the the simplest case first - just Document as the param 
  +            /////////////////////////////////////////////////////////////////
  +            argClasses = new Class[1];
  +            argObjects = new Object[1];
  +            argClasses[0] = msgContext.getClassLoader().loadClass("org.w3c.dom.Document");
  +            argObjects[0] = doc ;
  +
  +            try {
  +              method = jc.getJavaClass().getMethod( methodName, argClasses );
  +            }
  +            catch( NoSuchMethodException exp ) {
  +              // Ok, no match - so now add MessageContext as the first param
  +              // and try it again
  +              ///////////////////////////////////////////////////////////////
  +              argClasses = new Class[2];
  +              argObjects = new Object[2];
  +              argClasses[0] = msgContext.getClassLoader().loadClass("org.apache.axis.MessageContext");
  +              argClasses[1] = msgContext.getClassLoader().loadClass("org.w3c.dom.Document");
  +              argObjects[0] = msgContext ;
  +              argObjects[1] = doc ;
  +              method = jc.getJavaClass().getMethod( methodName, argClasses );
  +            }
  +
           } else {
               // pass *just* the MessageContext (maybe don't even parse!!!)
               argClasses = new Class[1];
               argObjects = new Object[1];
               argClasses[0] = msgContext.getClassLoader().loadClass("org.apache.axis.MessageContext");
               argObjects[0] = msgContext ;
  +            method = jc.getJavaClass().getMethod( methodName, argClasses );
           }
           
           
           // !!! WANT TO MAKE THIS SAX-CAPABLE AS WELL.  Some people will
           //     want DOM, but our examples should mostly lean towards the
           //     SAX side of things....
  -        
  -        Method       method = jc.getJavaClass().getMethod( methodName, argClasses );
           
           Document retDoc = (Document) method.invoke( obj, argObjects );