axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/transport/http HTTPDispatchHandler.java
Date Fri, 27 Apr 2001 15:24:36 GMT
gdaniels    01/04/27 08:24:36

  Modified:    java/src/org/apache/axis Message.java
               java/src/org/apache/axis/client AdminClient.java
                        HTTPMessage.java
               java/src/org/apache/axis/encoding SerializationContext.java
                        ServiceDescription.java
               java/src/org/apache/axis/handlers MsgDispatchHandler.java
               java/src/org/apache/axis/message SOAPSAXHandler.java
                        ThreadedSAXAdapter.java
               java/src/org/apache/axis/transport/http
                        HTTPDispatchHandler.java
  Log:
  Fix problem with deploy, cleanup.
  
  Summary:
  
  New Message form "BodyInputStream", which assumes the currentMessage
  object is an InputStream pointing at some XML which should be in the
  body of the SOAP envelope.  New subtype of SOAPBodyElement called
  InputStreamBody which encapsulates this input stream.  When asked to
  output() to the SerializationContext, it just writes the stream.
  
  (NOTE: there are potential problems embedding XML inside XML like this,
  but we'll leave them for theorizing about later)
  
  There is also a new body type called "DOMBody" which encapsulates a
  DOM Element, and walks the element to output XML during serialization.
  This is to allow programmatic construction of bodies (such as we do in
  MsgDispatchHandler).
  
  To be able to distinguish which kind of body to create, I threaded the
  ServiceDescription down through the Message object and the
  SOAPSAXHandler so that clients can set it before the SOAP envelope
  gets parsed.  Then at parse time, if the service is registered as RPC,
  we make an RPCBody, otherwise a plain old SOAPBodyElement.  This
  needs some more thinking, both in terms of cleaning up the design and
  also potentially dealing with a situation where you don't know if it's an
  RPC until after you parse (i.e. when doing dispatch based on the body
  element's namespace).
  
  Also did some general cleanup, removed a few debugging printlns, etc.
  
  Revision  Changes    Path
  1.20      +27 -1     xml-axis/java/src/org/apache/axis/Message.java
  
  Index: Message.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Message.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Message.java	2001/04/27 02:41:55	1.19
  +++ Message.java	2001/04/27 15:24:11	1.20
  @@ -61,6 +61,7 @@
   import org.xml.sax.*;
   
   import org.apache.axis.encoding.SerializationContext;
  +import org.apache.axis.encoding.ServiceDescription;
   import org.apache.axis.message.* ;
   import org.apache.axis.utils.Debug ;
   import org.apache.axis.utils.XMLUtils ;
  @@ -79,6 +80,7 @@
     private Object currentMessage ;
     private String currentForm ;
     private boolean isResponse = false;
  +  private ServiceDescription serviceDesc = null;
   
     /**
      * Just something to us working...
  @@ -103,6 +105,15 @@
     }
     
     public void markAsResponse() { isResponse = true; }
  +  
  +  public ServiceDescription getServiceDescription()
  +  {
  +      return serviceDesc;
  +  }
  +  public void setServiceDescription(ServiceDescription serviceDesc)
  +  {
  +      this.serviceDesc = serviceDesc;
  +  }
   
     public void setCurrentMessage(Object currMsg, String form) {
       Debug.Print( 2, "Setting current message form to: " + form );
  @@ -122,6 +133,7 @@
       if ( desiredType.equals( "Document" )) return( getAsDocument() );
       if ( desiredType.equals( "String" )) return( getAsString() );
       if ( desiredType.equals( "SOAPEnvelope" )) return( getAsSOAPEnvelope() );
  +    // ??? if ( desiredType.equals( "BodyInputStream" )) return( getAsBodyInputStream()
);
   
       System.err.println("Can't convert " + currentForm + " to " +desiredType);
       return( null );
  @@ -133,6 +145,10 @@
         Debug.Print( 2, "Exit: Message::getAsByes" );
         return( (byte[]) currentMessage );
       }
  +    
  +    if ( currentForm.equals("BodyInputStream") ) {
  +        getAsSOAPEnvelope();
  +    }
   
       if ( currentForm.equals("InputStream") ) {
         // Assumes we don't need a content length
  @@ -174,7 +190,8 @@
         return( (String) currentMessage );
       }
   
  -    if ( currentForm.equals("InputStream") ) {
  +    if ( currentForm.equals("InputStream") ||
  +         currentForm.equals("BodyInputStream") ) {
         getAsBytes();
         // Fall thru to "Bytes"
       }
  @@ -275,6 +292,14 @@
       if ( currentForm.equals("SOAPEnvelope") ) 
         return( (SOAPEnvelope) currentMessage );
       
  +    if (currentForm.equals("BodyInputStream")) {
  +      InputStreamBody bodyEl = new InputStreamBody((InputStream)currentMessage);
  +      SOAPEnvelope env = new SOAPEnvelope();
  +      env.addBodyElement(bodyEl);
  +      setCurrentMessage(env, "SOAPEnvelope");
  +      return env;
  +    }
  +    
       InputSource is;
   
       if ( currentForm.equals("InputStream") ) {
  @@ -285,6 +310,7 @@
       
       ThreadedSAXAdapter parser = 
           new ThreadedSAXAdapter(new org.apache.xerces.parsers.SAXParser(), is);
  +    parser.setServiceDescription(serviceDesc);
       
       setCurrentMessage( parser.getEnvelope(), "SOAPEnvelope" );
       Debug.Print( 2, "Exit: Message::getAsSOAPEnvelope" );
  
  
  
  1.15      +4 -1      xml-axis/java/src/org/apache/axis/client/AdminClient.java
  
  Index: AdminClient.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/AdminClient.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AdminClient.java	2001/03/30 19:26:14	1.14
  +++ AdminClient.java	2001/04/27 15:24:14	1.15
  @@ -64,6 +64,7 @@
   import org.apache.axis.MessageContext ;
   import org.apache.axis.client.HTTPMessage ;
   import org.apache.axis.utils.Debug ;
  +import org.apache.axis.encoding.ServiceDescription;
   
   /**
    *
  @@ -100,7 +101,7 @@
           HTTPMessage     hMsg       = new HTTPMessage( opts.getURL(), 
                                                         "AdminService" );
           MessageContext  msgContext = new MessageContext();
  -        Message         inMsg      = new Message( input, "InputStream" );
  +        Message         inMsg      = new Message( input, "BodyInputStream" );
           Message         outMsg     = null ;
           msgContext.setRequestMessage( inMsg );
   
  @@ -111,7 +112,9 @@
           hMsg.invoke( msgContext );
   
           outMsg = msgContext.getResponseMessage();
  +        outMsg.setServiceDescription(new ServiceDescription("Admin", false));
           input.close();
  +        outMsg.getAs("SOAPEnvelope");
           System.out.println( outMsg.getAs( "String" ) );
         }
       }
  
  
  
  1.27      +1 -1      xml-axis/java/src/org/apache/axis/client/HTTPMessage.java
  
  Index: HTTPMessage.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/HTTPMessage.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- HTTPMessage.java	2001/04/26 22:57:28	1.26
  +++ HTTPMessage.java	2001/04/27 15:24:15	1.27
  @@ -228,7 +228,7 @@
       }
   
       Message       resMsg = msgContext.getResponseMessage();
  -    SOAPEnvelope  resEnv = (SOAPEnvelope) resMsg.getAs( "SOAPEnvelope" );
  +    //SOAPEnvelope  resEnv = (SOAPEnvelope) resMsg.getAs( "SOAPEnvelope" );
       mc.setResponseMessage(resMsg);
       /*
       SOAPBody      resBody = null; //resEnv.getFirstBody();
  
  
  
  1.2       +9 -0      xml-axis/java/src/org/apache/axis/encoding/SerializationContext.java
  
  Index: SerializationContext.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/SerializationContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SerializationContext.java	2001/04/26 23:03:08	1.1
  +++ SerializationContext.java	2001/04/27 15:24:18	1.2
  @@ -136,6 +136,10 @@
       public void startElement(QName qName, Attributes attributes)
           throws IOException
       {
  +        if (DEBUG_LOG) {
  +            System.out.println("Out: Starting element [" + qName.getNamespaceURI() + "]:"
+ qName.getLocalPart());
  +        }
  +        
           if (writingStartTag) {
               writer.write(">");
           }
  @@ -190,6 +194,11 @@
           throws IOException
       {
           String elementQName = (String)elementStack.pop();
  +        
  +        if (DEBUG_LOG) {
  +            System.out.println("Out: Ending element " + elementQName);
  +        }
  +        
           nsStack.pop();
   
           if (writingStartTag) {
  
  
  
  1.2       +8 -1      xml-axis/java/src/org/apache/axis/encoding/ServiceDescription.java
  
  Index: ServiceDescription.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ServiceDescription.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServiceDescription.java	2001/04/26 23:03:08	1.1
  +++ ServiceDescription.java	2001/04/27 15:24:19	1.2
  @@ -75,6 +75,7 @@
       public static final String RESPONSE = "Response";
       
       String name;
  +    boolean serviceIsRPC = true;
       
       class Param {
           public String name;
  @@ -100,9 +101,15 @@
       // Should we tack on "xsi:type" attributes?
       public boolean sendXsiType = true;
       
  -    public ServiceDescription(String name)
  +    public ServiceDescription(String name, boolean isRPC)
       {
           this.name = name;
  +        this.serviceIsRPC = isRPC;
  +    }
  +    
  +    public boolean isRPC()
  +    {
  +        return this.serviceIsRPC;
       }
       
       public void addInputParam(String name, QName type)
  
  
  
  1.18      +17 -8     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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- MsgDispatchHandler.java	2001/04/27 13:31:49	1.17
  +++ MsgDispatchHandler.java	2001/04/27 15:24:25	1.18
  @@ -61,6 +61,8 @@
   import org.apache.axis.* ;
   import org.apache.axis.utils.* ;
   import org.apache.axis.encoding.SerializationContext;
  +import org.apache.axis.encoding.ServiceDescription;
  +import org.apache.axis.message.DOMBody;
   import org.apache.axis.message.SOAPBodyElement;
   import org.apache.axis.message.SOAPEnvelope;
   import org.apache.axis.message.SOAPHeader;
  @@ -100,8 +102,21 @@
         Object          obj    = cls.newInstance();
         Class[]         argClasses = new Class[2];
         Object[]        argObjects = new Object[2];
  -
  +      
         Message       reqMsg  = msgContext.getRequestMessage();
  +
  +      /** !!! KLUDGE WARNING
  +       * We need some way of associating ServiceDescriptions with actual
  +       * services... and then at the point when we figure out which service
  +       * we'll be calling (which might be right away (static dispatch), after
  +       * looking at the URL (transport-level dispatch), or even after looking
  +       * into the SOAP message itself...)
  +       */
  +      if (clsName.equals("org.apache.axis.utils.Admin")) {
  +          ServiceDescription sd = new ServiceDescription("Admin", false);
  +          reqMsg.setServiceDescription(sd);
  +      }
  +
         SOAPEnvelope  reqEnv  = (SOAPEnvelope) reqMsg.getAs("SOAPEnvelope");
         
         System.err.println("Parsed the request message!");
  @@ -141,13 +156,7 @@
         Document retDoc = (Document) method.invoke( obj, argObjects );
     
         if ( retDoc != null ) {
  -          // !!! 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);
  +          SOAPBodyElement el = new DOMBody(retDoc.getDocumentElement());
             resEnv.addBodyElement(el);
         }
         
  
  
  
  1.2       +25 -1     xml-axis/java/src/org/apache/axis/message/SOAPSAXHandler.java
  
  Index: SOAPSAXHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPSAXHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SOAPSAXHandler.java	2001/04/26 22:53:40	1.1
  +++ SOAPSAXHandler.java	2001/04/27 15:24:29	1.2
  @@ -59,6 +59,7 @@
   import java.util.*;
   import org.apache.axis.*;
   import org.apache.axis.encoding.DeserializationContext;
  +import org.apache.axis.encoding.ServiceDescription;
   import org.apache.axis.utils.NSStack;
   import org.xml.sax.*;
   import org.xml.sax.helpers.DefaultHandler;
  @@ -116,6 +117,24 @@
       private int recordingDepth = 0;
   
       protected DeserializationContext context;
  +    protected ServiceDescription serviceDesc = null;
  +    
  +    class BodyFactory implements ElementFactory {
  +        public MessageElement createElement(String namespace,
  +                                            String localName,
  +                                            Attributes attributes,
  +                                            DeserializationContext context)
  +        {
  +            if ((serviceDesc != null) && (!serviceDesc.isRPC())) {
  +                return new SOAPBodyElement(namespace, localName, attributes, context);
  +            }
  +            
  +            return RPCElement.getFactory().createElement(namespace,
  +                                                         localName,
  +                                                         attributes,
  +                                                         context);
  +        }
  +    }
   
       /** These guys know how to create the right MessageElements (and thus
        * sub-handlers) for particular XML elements.  Right now the headers
  @@ -128,7 +147,7 @@
                               new ElementRegistry(SOAPHeader.factory());
       
       // Body factory. Only doing rpc bodies for right now...
  -    ElementFactory bodyFactory = RPCElement.getFactory();
  +    ElementFactory bodyFactory = new BodyFactory();
   
       public SOAPSAXHandler()
       {
  @@ -137,6 +156,11 @@
   
           // just testing...
           headerRegistry.registerFactory("urn:myNS", "Debug", DebugHeader.getFactory());
  +    }
  +    
  +    public void setServiceDescription(ServiceDescription serviceDesc)
  +    {
  +        this.serviceDesc = serviceDesc;
       }
       
       public int getState()
  
  
  
  1.2       +11 -3     xml-axis/java/src/org/apache/axis/message/ThreadedSAXAdapter.java
  
  Index: ThreadedSAXAdapter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/ThreadedSAXAdapter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ThreadedSAXAdapter.java	2001/04/26 22:53:40	1.1
  +++ ThreadedSAXAdapter.java	2001/04/27 15:24:30	1.2
  @@ -10,6 +10,8 @@
    */
   public class ThreadedSAXAdapter extends SOAPSAXHandler
   {
  +    private static final boolean DEBUG_LOG = false;
  +    
       private Object _semaphore = new Object();
                                              
       private XMLReader _parser;
  @@ -31,7 +33,9 @@
                   e.printStackTrace();
               }
               
  -            System.out.println("ThreadedSAXAdapter done.");
  +            if (DEBUG_LOG) {
  +                System.out.println("ThreadedSAXAdapter done.");
  +            }
               doneParsing = true;
               state = FINISHED;
               
  @@ -95,7 +99,9 @@
        */
       protected synchronized void continueParsing()
       {
  -        System.out.println("continueParsing()");
  +        if (DEBUG_LOG) {
  +            System.out.println("continueParsing()");
  +        }
           doneParsing = false;
           notify();
       }
  @@ -110,7 +116,9 @@
           if (parsingToEnd)
               return;
           
  -        System.out.println("pauseParsing()");
  +        if (DEBUG_LOG) {
  +            System.out.println("pauseParsing()");
  +        }
           
           synchronized (this) {
               doneParsing = true;
  
  
  
  1.17      +1 -1      xml-axis/java/src/org/apache/axis/transport/http/HTTPDispatchHandler.java
  
  Index: HTTPDispatchHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/HTTPDispatchHandler.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- HTTPDispatchHandler.java	2001/04/26 23:13:10	1.16
  +++ HTTPDispatchHandler.java	2001/04/27 15:24:33	1.17
  @@ -166,7 +166,7 @@
   
         reqEnv  = (String) msgContext.getRequestMessage().getAs("String");
         
  -      System.out.println("Msg: " + reqEnv);
  +      //System.out.println("Msg: " + reqEnv);
   
         OutputStream  out  = sock.getOutputStream();
         InputStream   inp  = sock.getInputStream();
  
  
  

Mime
View raw message