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 gd...@apache.org on 2001/04/27 01:07:04 UTC

cvs commit: xml-axis/java/src/org/apache/axis/handlers DebugHandler.java EchoHandler.java MsgDispatchHandler.java RPCDispatchHandler.java

gdaniels    01/04/26 16:07:04

  Modified:    java/src/org/apache/axis/handlers DebugHandler.java
                        EchoHandler.java MsgDispatchHandler.java
                        RPCDispatchHandler.java
  Log:
  Changes for new message model.
  
  NOTE:  Message dispatch is currently broken!  We need a way of injecting
  DOM into the body of a SOAPEnvelope for responses to work.
  
  Also, we should migrate MsgDispatchHandler to using SAX.... we should
  provide DOM upon request, but make SAX the easy choice for XML
  processing at high speed.
  
  Revision  Changes    Path
  1.11      +12 -4     xml-axis/java/src/org/apache/axis/handlers/DebugHandler.java
  
  Index: DebugHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/DebugHandler.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DebugHandler.java	2001/03/30 20:17:29	1.10
  +++ DebugHandler.java	2001/04/26 23:07:04	1.11
  @@ -59,9 +59,7 @@
   
   import org.apache.axis.* ;
   import org.apache.axis.utils.* ;
  -import org.apache.axis.message.RPCArg;
  -import org.apache.axis.message.RPCBody;
  -import org.apache.axis.message.SOAPBody;
  +import org.apache.axis.message.DebugHeader;
   import org.apache.axis.message.SOAPEnvelope;
   import org.apache.axis.message.SOAPHeader;
   
  @@ -77,6 +75,16 @@
           Debug.Print( 1, "Enter: DebugHandler::invoke" );
           try {
               Message       msg = msgContext.getRequestMessage();
  +            
  +            SOAPEnvelope message = (SOAPEnvelope)msg.getAs("SOAPEnvelope");
  +            SOAPHeader header = message.getHeaderByName(Constants.URI_DEBUG, "Debug");
  +            if ((header != null) && (header instanceof DebugHeader)) {
  +                int debugVal = ((DebugHeader)header).getDebugLevel();
  +                Debug.Print( 1, "Setting debug level to: " + debugVal );
  +                Debug.setDebugLevel(debugVal);
  +                header.setProcessed(true);
  +            }
  +            /*
               SOAPEnvelope  env = (SOAPEnvelope) msg.getAs( "SOAPEnvelope" );
               Vector        headers = null ;
               int           i ;
  @@ -89,13 +97,13 @@
                   String      value = root.getFirstChild().getNodeValue();
                   if ( value != null ) {
                       int     debugVal = Integer.parseInt( value );
  -                    Debug.Print( 1, "Setting debug level to: " + debugVal );
                       Debug.setDebugLevel( debugVal );
                       header.setProcessed( true );
                   }
               }
               if ( i == 0 )
                 Debug.setDebugLevel( 0 );
  +            */
           }
           catch( Exception e ) {
               Debug.Print( 1, e );
  
  
  
  1.14      +0 -4      xml-axis/java/src/org/apache/axis/handlers/EchoHandler.java
  
  Index: EchoHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/EchoHandler.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- EchoHandler.java	2001/03/26 21:11:50	1.13
  +++ EchoHandler.java	2001/04/26 23:07:04	1.14
  @@ -57,11 +57,7 @@
   
   import org.apache.axis.* ;
   import org.apache.axis.utils.* ;
  -import org.apache.axis.message.RPCArg;
  -import org.apache.axis.message.RPCBody;
  -import org.apache.axis.message.SOAPBody;
   import org.apache.axis.message.SOAPEnvelope;
  -import org.apache.axis.message.SOAPHeader;
   
   /**
    *
  
  
  
  1.16      +25 -9     xml-axis/java/src/org/apache/axis/handlers/MsgDispatchHandler.java
  
  Index: MsgDispatchHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/MsgDispatchHandler.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- MsgDispatchHandler.java	2001/03/31 00:53:09	1.15
  +++ MsgDispatchHandler.java	2001/04/26 23:07:04	1.16
  @@ -60,14 +60,14 @@
   import java.lang.reflect.* ;
   import org.apache.axis.* ;
   import org.apache.axis.utils.* ;
  -import org.apache.axis.message.RPCArg;
  -import org.apache.axis.message.RPCBody;
  -import org.apache.axis.message.SOAPBody;
  +import org.apache.axis.encoding.SerializationContext;
  +import org.apache.axis.message.SOAPBodyElement;
   import org.apache.axis.message.SOAPEnvelope;
   import org.apache.axis.message.SOAPHeader;
   import org.apache.axis.handlers.* ;
   
   import org.w3c.dom.* ;
  +import org.xml.sax.*;
   
   /**
    *
  @@ -103,15 +103,25 @@
   
         Message       reqMsg  = msgContext.getRequestMessage();
         SOAPEnvelope  reqEnv  = (SOAPEnvelope) reqMsg.getAs("SOAPEnvelope");
  -      SOAPBody      reqBody = reqEnv.getFirstBody();
  +      
  +      System.err.println("Parsed the request message!");
  +      
  +      SOAPBodyElement reqBody = reqEnv.getFirstBody();
         Message       resMsg  = msgContext.getResponseMessage();
         SOAPEnvelope  resEnv  = (resMsg == null) ?
                                 new SOAPEnvelope() :
                                 (SOAPEnvelope)resMsg.getAs("SOAPEnvelope");
  +      
  +      StringWriter writer = new StringWriter();
  +      reqBody.output(new SerializationContext(writer));
  +      
  +      InputStream inStream = new StringBufferInputStream(writer.getBuffer().toString());
  +      Document doc = XMLUtils.newDocument(inStream);
  +      
  +      // !!! 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....
   
  -      Document doc = XMLUtils.newDocument();
  -      doc.appendChild( doc.importNode(reqBody.getRoot(),true) );
  -
         /* If no methodName was specified during deployment then get it */
         /* from the root of the Body element                            */
         /* Hmmm, should we do this????                                  */
  @@ -131,8 +141,14 @@
         Document retDoc = (Document) method.invoke( obj, argObjects );
     
         if ( retDoc != null ) {
  -        SOAPBody resBody = new SOAPBody( retDoc );
  -        resEnv.addBody(resBody);
  +          // !!! This doesn't really work yet... need to figure out how to
  +          //     inject XML into just the Body of a message.....
  +          
  +          SOAPBodyElement el = new SOAPBodyElement();
  +          String retString = XMLUtils.DocumentToString(retDoc);
  +          System.out.println(retString);
  +          el.setValue(retString);
  +          resEnv.addBodyElement(el);
         }
         
         if (resMsg == null) {
  
  
  
  1.26      +12 -16    xml-axis/java/src/org/apache/axis/handlers/RPCDispatchHandler.java
  
  Index: RPCDispatchHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/RPCDispatchHandler.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- RPCDispatchHandler.java	2001/04/22 12:17:10	1.25
  +++ RPCDispatchHandler.java	2001/04/26 23:07:04	1.26
  @@ -59,11 +59,7 @@
   import java.lang.reflect.* ;
   import org.apache.axis.* ;
   import org.apache.axis.utils.* ;
  -import org.apache.axis.message.RPCArg;
  -import org.apache.axis.message.RPCBody;
  -import org.apache.axis.message.SOAPBody;
  -import org.apache.axis.message.SOAPEnvelope;
  -import org.apache.axis.message.SOAPHeader;
  +import org.apache.axis.message.* ;
   
   /**
    *
  @@ -94,7 +90,7 @@
         Message         inMsg  = msgContext.getRequestMessage();
         Message         outMsg = msgContext.getResponseMessage();
         SOAPEnvelope    env    = (SOAPEnvelope) inMsg.getAs("SOAPEnvelope");
  -      Vector          bodies = env.getAsRPCBody();
  +      Vector          bodies = env.getBodyElements();
         SOAPEnvelope    resEnv = (outMsg == null) ?
                                   new SOAPEnvelope() :
                                   (SOAPEnvelope)outMsg.getAs("SOAPEnvelope");
  @@ -103,9 +99,12 @@
         /* RPC call.                                                      */
         /******************************************************************/
         for ( int bNum = 0 ; bNum < bodies.size() ; bNum++ ) {
  -        RPCBody      body  = (RPCBody) bodies.get( bNum );
  +        if (!(bodies.get(bNum) instanceof RPCElement))
  +            continue;
  +        
  +        RPCElement   body  = (RPCElement) bodies.get( bNum );
           String       mName = body.getMethodName();
  -        Vector       args  = body.getArgs();        //RPCArg's
  +        Vector       args  = body.getParams();
     
           if ( methodName != null && !methodName.equals(mName) )
             throw new AxisFault( "AxisServer.error", 
  @@ -123,7 +122,7 @@
             argValues = new Object[ args.size()];
             for ( i = 0 ; i < args.size() ; i++ ) {
               argClasses[i] = cl.loadClass("java.lang.String") ;
  -            argValues[i]  = ((RPCArg)args.get(i)).getValue() ; // String 4now
  +            argValues[i]  = ((RPCParam)args.get(i)).getValue() ;
               Debug.Print( 2, "  class: " + argClasses[i] );
               Debug.Print( 2, "  value: " + argValues[i] == null ? 
                                                "null" :
  @@ -136,17 +135,14 @@
     
           /* Now put the result in the result SOAPEnvelope */
           /*************************************************/
  -        RPCBody resBody = new RPCBody();
  -        resBody.setMethodName( mName + "Response" );
  +        RPCElement resBody = new RPCElement(mName + "Response");
           resBody.setPrefix( body.getPrefix() );
           resBody.setNamespaceURI( body.getNamespaceURI() );
           if ( objRes != null ) {
  -          RPCArg  arg = new RPCArg();
  -          arg.setName( "return" );
  -          arg.setValue( objRes.toString() );
  -          resBody.addArg( arg );
  +          RPCParam param = new RPCParam("return", objRes);
  +          resBody.addParam(param);
           }
  -        resEnv.addBody( resBody.getAsSOAPBody() );
  +        resEnv.addBodyElement( resBody );
         }
   
         if (outMsg == null) {