axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ja...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/transport/http HTTPDispatchHandler.java AxisServlet.java HTTPConstants.java
Date Mon, 12 Feb 2001 01:11:18 GMT
jacek       01/02/11 17:11:17

  Modified:    java/src/org/apache/axis Constants.java MessageContext.java
               java/src/org/apache/axis/client EchoClient.java
                        HTTPCall.java HTTPMessage.java
                        TransportRoutingClient.java
               java/src/org/apache/axis/handlers HTTPActionHandler.java
                        MsgDispatchHandler.java RPCDispatchHandler.java
                        Router.java ServiceHandler.java
                        SimpleAuthenticationHandler.java
                        SimpleAuthorizationHandler.java
               java/src/org/apache/axis/server SimpleAxisEngine.java
               java/src/org/apache/axis/transport/http AxisServlet.java
                        HTTPConstants.java
  Added:       java/src/org/apache/axis/transport/http
                        HTTPDispatchHandler.java
  Removed:     java/src/org/apache/axis/handlers HTTPDispatchHandler.java
  Log:
  More cleanup and constant shuffling and documentation updates.
  
  Revision  Changes    Path
  1.4       +0 -21     xml-axis/java/src/org/apache/axis/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Constants.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Constants.java	2001/02/10 04:39:53	1.3
  +++ Constants.java	2001/02/12 01:11:11	1.4
  @@ -64,27 +64,6 @@
     public static String HANDLER_REGISTRY = "HandlerRegistry" ;
     public static String SERVICE_REGISTRY = "ServiceRegistry" ;
   
  -  // MessageContext Property Names
  -  // (A hierarchical namespace is strongly suggested 
  -  //  in order to lower the chance for conflicts)
  -  //////////////////////////////////////////////////////////////////////////
  -  public static String MC_SVC_HANDLER   = "service.handler" ;   // Handler
  -  
  -  public static String MC_TARGET        = "service.target";
  -
  -  public static String MC_HTTP_STATUS_CODE    = "transport.http.statusCode" ;    
  -                                                              // Integer
  -  public static String MC_HTTP_STATUS_MESSAGE = "transport.http.statusMessage" ; 
  -                                                              // String
  -  public static String MC_TRANS_URL           = "transport.url" ;
  -                                                              // String
  -  // this can be put into MC_TRANS_SOAPACTION if more transports have it
  -  public static String MC_HTTP_SOAPACTION     = "transport.soapAction" ;      
  -                                                              // String
  -  
  -  public static String MC_USERID   = "user.id" ;              // String
  -  public static String MC_PASSWORD = "user.password" ;        // String
  -
     // Envelope Stuff
     //////////////////////////////////////////////////////////////////////////
     public static String NSPREFIX_SOAP_ENV   = "SOAP-ENV" ;
  
  
  
  1.8       +53 -0     xml-axis/java/src/org/apache/axis/MessageContext.java
  
  Index: MessageContext.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/MessageContext.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- MessageContext.java	2001/02/10 04:39:53	1.7
  +++ MessageContext.java	2001/02/12 01:11:11	1.8
  @@ -59,8 +59,27 @@
   import org.apache.axis.* ;
   
   /**
  + * Some more general docs will go here.
    *
  + * This class also contains constants for accessing some
  + * well-known properties. Using a hierarchical namespace is
  + * strongly suggested in order to lower the chance for
  + * conflicts.
  + *
  + * (These constants should be viewed as an explicit list of well
  + *  known and widely used context keys, there's nothing wrong
  + *  with directly using the key strings. This is the reason for
  + *  the hierarchical constant namespace.
  + *
  + *  Actually I think we might just list the keys in the docs and
  + *  provide no such constants since they create yet another
  + *  namespace, but we'd have no compile-time checks then. 
  + *
  + *  Whaddya think? - todo by Jacek)
  + *
  + *
    * @author Doug Davis (dug@us.ibm.com)
  + * @author Jacek Kopecky (jacek@idoox.com)
    */
   public class MessageContext {
       /**
  @@ -112,6 +131,40 @@
           outMessage = inMsg ;
       };
   
  +    /** Contains an instance of Handler, which is the
  +     *  ServiceContext and the entrypoint of this service.
  +     *
  +     *  (if it has been so configured - will our deployment
  +     *   tool do this by default?  - todo by Jacek)
  +     */
  +    public static String SVC_HANDLER         = "service.handler";
  +
  +    /** Contains a String that should uniquely identify the
  +     *  service that the current message is being sent to
  +     */
  +    public static String TARGET_SERVICE      = "service.target";
  +
  +
  +    /** This String is the URL that the message came to
  +     */
  +    public static String TRANS_URL           = "transport.url";
  +
  +    /** This String identifies the transport through which this
  +     *  message has come. This will be (todo) used for
  +     *  identifying the transport chain.
  +     */
  +    public static String TRANS_ID            = "transport.id";
  +
  +   
  +    /** A String with the user's ID (if available)
  +     */
  +    public static String USERID              = "user.id";
  +
  +    /** A String with the user's password (if available)
  +     */
  +    public static String PASSWORD            = "user.password";
  +
  +   
       public Object getProperty(String propName) {
           if ( bag == null ) return( null );
           return( bag.get(propName) );
  
  
  
  1.12      +1 -1      xml-axis/java/src/org/apache/axis/client/EchoClient.java
  
  Index: EchoClient.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/EchoClient.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- EchoClient.java	2001/02/10 04:39:54	1.11
  +++ EchoClient.java	2001/02/12 01:11:12	1.12
  @@ -121,7 +121,7 @@
                   msgContext.setIncomingMessage(message);
                   
                   // This is fixed, as this client tightly binds to the echo service.
  -                msgContext.setProperty(Constants.MC_TARGET, "EchoService");
  +                msgContext.setProperty(MessageContext.TARGET_SERVICE, "EchoService");
                   engine.init();
                   engine.invoke(msgContext);
                   
  
  
  
  1.9       +7 -5      xml-axis/java/src/org/apache/axis/client/HTTPCall.java
  
  Index: HTTPCall.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/HTTPCall.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- HTTPCall.java	2001/02/10 04:39:54	1.8
  +++ HTTPCall.java	2001/02/12 01:11:12	1.9
  @@ -63,6 +63,8 @@
   import org.apache.axis.handlers.* ;
   import org.apache.axis.utils.* ;
   import org.apache.axis.* ;
  +import org.apache.axis.transport.http.HTTPConstants;
  +import org.apache.axis.transport.http.HTTPDispatchHandler;
   
   /**
    *
  @@ -130,7 +132,7 @@
       RPCBody              body   = new RPCBody( method, args );
       SOAPEnvelope         reqEnv = new SOAPEnvelope();
       SOAPEnvelope         resEnv = null ;
  -    HTTPDispatchHandler  client = new HTTPDispatchHandler();
  +    Handler              client = new HTTPDispatchHandler();
       Message              reqMsg = new Message( reqEnv, "SOAPEnvelope" );
       Message              resMsg = null ;
       MessageContext       msgContext = new MessageContext( reqMsg );
  @@ -156,12 +158,12 @@
         reqEnv.addHeader( header );
       }
   
  -    msgContext.setProperty( Constants.MC_TRANS_URL, url );
  -    msgContext.setProperty( Constants.MC_HTTP_SOAPACTION, action );
  +    msgContext.setProperty( MessageContext.TRANS_URL, url );
  +    msgContext.setProperty( HTTPConstants.MC_HTTP_SOAPACTION, action );
       if ( userID != null ) {
  -      msgContext.setProperty( Constants.MC_USERID, userID );
  +      msgContext.setProperty( MessageContext.USERID, userID );
         if ( passwd != null )
  -        msgContext.setProperty( Constants.MC_PASSWORD, passwd );
  +        msgContext.setProperty( MessageContext.PASSWORD, passwd );
       }
       try {
         client.init();
  
  
  
  1.6       +5 -3      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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- HTTPMessage.java	2001/02/10 04:39:54	1.5
  +++ HTTPMessage.java	2001/02/12 01:11:13	1.6
  @@ -63,6 +63,8 @@
   import org.apache.axis.handlers.* ;
   import org.apache.axis.* ;
   import org.apache.axis.utils.* ;
  +import org.apache.axis.transport.http.HTTPConstants;
  +import org.apache.axis.transport.http.HTTPDispatchHandler;
   
   /**
    *
  @@ -114,7 +116,7 @@
       Element              root = doc.getDocumentElement();
       SOAPBody             reqBody = new SOAPBody( root );
       SOAPEnvelope         reqEnv = new SOAPEnvelope();
  -    HTTPDispatchHandler  client = new HTTPDispatchHandler();
  +    Handler              client = new HTTPDispatchHandler();
       Message              reqMsg = new Message( reqEnv, "SOAPEnvelope" );
       MessageContext       msgContext = new MessageContext( reqMsg );
   
  @@ -125,8 +127,8 @@
         // Debug.Print( 1, (String) reqMsg.getAs("String") );
       // }
   
  -    msgContext.setProperty( Constants.MC_TRANS_URL, url );
  -    msgContext.setProperty( Constants.MC_HTTP_SOAPACTION, action );
  +    msgContext.setProperty( MessageContext.TRANS_URL, url );
  +    msgContext.setProperty( HTTPConstants.MC_HTTP_SOAPACTION, action );
       try {
         client.init();
         client.invoke( msgContext );
  
  
  
  1.3       +5 -4      xml-axis/java/src/org/apache/axis/client/TransportRoutingClient.java
  
  Index: TransportRoutingClient.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/TransportRoutingClient.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TransportRoutingClient.java	2001/02/10 04:39:54	1.2
  +++ TransportRoutingClient.java	2001/02/12 01:11:13	1.3
  @@ -61,11 +61,12 @@
   
   import org.apache.axis.*;
   import org.apache.axis.server.SimpleAxisEngine;
  +import org.apache.axis.transport.http.HTTPConstants;
   
   /** This is a quick in-memory client to demonstrate how transport-dependent
    * routing works.  It pretends to be the AxisServlet with a SOAPAction header
    * of "EchoService".  This ends up calling the AxisServlet chain, which
  - * sets the new TARGET to be the value of the SOAPAction header, and then
  + * sets the new TARGET_SERVICE to be the value of the SOAPAction header, and then
    * uses the Router handler to dispatch to the service.
    *
    * @author Glen Daniels (gdaniels@allaire.com)
  @@ -93,14 +94,14 @@
               Message message = new Message(msg, "String");
               msgContext.setIncomingMessage(message);
               
  -            /** The TARGET is "AxisServlet"
  +            /** The transport is http.
                */
  -            msgContext.setProperty(Constants.MC_TARGET, "AxisServlet");
  +            msgContext.setProperty(MessageContext.TRANS_ID, HTTPConstants.TRANSPORT_ID);
               
               /** If we were a real servlet, we might have made the SOAPAction
                * HTTP header available like this...
                */
  -            msgContext.setProperty(Constants.MC_HTTP_SOAPACTION, "EchoService");
  +            msgContext.setProperty(HTTPConstants.MC_HTTP_SOAPACTION, "EchoService");
   
               engine.init();
               engine.invoke(msgContext);
  
  
  
  1.3       +5 -4      xml-axis/java/src/org/apache/axis/handlers/HTTPActionHandler.java
  
  Index: HTTPActionHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/HTTPActionHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HTTPActionHandler.java	2001/02/11 22:07:17	1.2
  +++ HTTPActionHandler.java	2001/02/12 01:11:14	1.3
  @@ -57,14 +57,15 @@
   import org.apache.axis.*;
   import org.apache.axis.registries.SimpleServiceRegistry;
   import org.apache.axis.utils.Debug;
  +import org.apache.axis.transport.http.HTTPConstants;
   
  -/** An <code>HTTPActionHandler</code> simply sets the context's TARGET
  +/** An <code>HTTPActionHandler</code> simply sets the context's TARGET_SERVICE
    * property from the HTTPAction property.  We expect there to be a
    * Router on the chain after us, to dispatch to the service named in
    * the SOAPAction.
    * 
    * In the real world, this might do some more complex mapping of
  - * SOAPAction to a TARGET.
  + * SOAPAction to a TARGET_SERVICE.
    * 
    * @author Glen Daniels (gdaniels@allaire.com)
    * @author Doug Davis (dug@us.ibm.com)
  @@ -74,11 +75,11 @@
       public void invoke(MessageContext msgContext) throws AxisFault
       {
           Debug.Print( 1, "Enter: HTTPActionHandler::invoke" );
  -        String action = (String)msgContext.getProperty(Constants.MC_HTTP_SOAPACTION);
  +        String action = (String)msgContext.getProperty(HTTPConstants.MC_HTTP_SOAPACTION);
           if (action == null)
               throw new AxisFault(new NullPointerException("HTTPActionHandler: No HTTPAction
property in context!"));
   
  -        msgContext.setProperty(Constants.MC_TARGET, action);
  +        msgContext.setProperty(MessageContext.TARGET_SERVICE, action);
           Debug.Print( 1, "Exit : HTTPActionHandler::invoke" );
       }
   
  
  
  
  1.4       +1 -1      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MsgDispatchHandler.java	2001/02/11 22:07:17	1.3
  +++ MsgDispatchHandler.java	2001/02/12 01:11:14	1.4
  @@ -80,7 +80,7 @@
       /* Find the service we're invoking so we can grab it's options */
       /***************************************************************/
       Handler service ;
  -    service = (Handler) msgContext.getProperty( Constants.MC_SVC_HANDLER );
  +    service = (Handler) msgContext.getProperty( MessageContext.SVC_HANDLER );
   
       /* Now get the service (RPC) specific info  */
       /********************************************/
  
  
  
  1.10      +1 -1      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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- RPCDispatchHandler.java	2001/02/10 04:39:55	1.9
  +++ RPCDispatchHandler.java	2001/02/12 01:11:15	1.10
  @@ -73,7 +73,7 @@
       /* Find the service we're invoking so we can grab it's options */
       /***************************************************************/
       Handler service ;
  -    service = (Handler) msgContext.getProperty( Constants.MC_SVC_HANDLER );
  +    service = (Handler) msgContext.getProperty( MessageContext.SVC_HANDLER );
   
       /* Now get the service (RPC) specific info  */
       /********************************************/
  
  
  
  1.3       +7 -7      xml-axis/java/src/org/apache/axis/handlers/Router.java
  
  Index: Router.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/Router.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Router.java	2001/02/11 22:07:18	1.2
  +++ Router.java	2001/02/12 01:11:15	1.3
  @@ -59,7 +59,7 @@
   import org.apache.axis.utils.Debug;
   
   /** A <code>Router</code> is a Handler which has only one purpose in life:
  - * to look up the TARGET property in the passed MessageContext, then look
  + * to look up the TARGET_SERVICE property in the passed MessageContext, then look
    * up a Handler under that name in the ServiceRegistry.  Then it passes
    * the MessageContext off to that Handler.
    * 
  @@ -75,7 +75,7 @@
           if (registry == null)
               throw new AxisFault(new NullPointerException("Router: No registry property
in context!"));
           
  -        String target = (String)msgContext.getProperty(Constants.MC_TARGET);
  +        String target = (String)msgContext.getProperty(MessageContext.TARGET_SERVICE);
           if (target == null)
               throw new AxisFault(new NullPointerException("Router: No target property in
context!"));
           
  @@ -85,11 +85,11 @@
               throw new AxisFault(new Exception("Router: Couldn't find service '" + target
+ "' in the registry!"));
           
           // Make sure next dispatch, if any, is clean so we don't loop back.
  -        msgContext.clearProperty(Constants.MC_TARGET);
  +        msgContext.clearProperty(MessageContext.TARGET_SERVICE);
           
           h.invoke(msgContext);
   
  -        msgContext.setProperty(Constants.MC_TARGET, target);
  +        msgContext.setProperty(MessageContext.TARGET_SERVICE, target);
           Debug.Print( 1, "Exit : Router::invoke" );
       }
   
  @@ -98,16 +98,16 @@
           Debug.Print( 1, "Enter: Router::undo" );
           SimpleServiceRegistry registry = (SimpleServiceRegistry)msgContext.getProperty(Constants.SERVICE_REGISTRY);
           
  -        String target = (String)msgContext.getProperty(Constants.MC_TARGET);
  +        String target = (String)msgContext.getProperty(MessageContext.TARGET_SERVICE);
           
           Handler h = registry.find( target );
   
           // Make sure next dispatch, if any, is clean so we don't loop back.
  -        msgContext.clearProperty(Constants.MC_TARGET);
  +        msgContext.clearProperty(MessageContext.TARGET_SERVICE);
           
           h.undo(msgContext);
   
  -        msgContext.setProperty(Constants.MC_TARGET, target);
  +        msgContext.setProperty(MessageContext.TARGET_SERVICE, target);
           Debug.Print( 1, "Exit: Router::undo" );
       }
   }
  
  
  
  1.6       +1 -1      xml-axis/java/src/org/apache/axis/handlers/ServiceHandler.java
  
  Index: ServiceHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/ServiceHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ServiceHandler.java	2001/02/10 04:39:55	1.5
  +++ ServiceHandler.java	2001/02/12 01:11:15	1.6
  @@ -84,7 +84,7 @@
   
     public void invoke(MessageContext msgContext) throws AxisFault {
       // Let our "real" handler know where we are, so it can get options.
  -    msgContext.setProperty( Constants.MC_SVC_HANDLER, this );
  +    msgContext.setProperty( MessageContext.SVC_HANDLER, this );
           
       handler.invoke(msgContext);
     }
  
  
  
  1.5       +2 -2      xml-axis/java/src/org/apache/axis/handlers/SimpleAuthenticationHandler.java
  
  Index: SimpleAuthenticationHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/SimpleAuthenticationHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SimpleAuthenticationHandler.java	2001/02/11 22:07:18	1.4
  +++ SimpleAuthenticationHandler.java	2001/02/12 01:11:15	1.5
  @@ -75,8 +75,8 @@
     public void invoke(MessageContext msgContext) throws AxisFault {
       Debug.Print( 1, "Enter: SimpleAuthenticationHandler::invoke" );
       try {
  -      String  userID = (String) msgContext.getProperty( Constants.MC_USERID );
  -      String  passwd = (String) msgContext.getProperty( Constants.MC_PASSWORD );
  +      String  userID = (String) msgContext.getProperty( MessageContext.USERID );
  +      String  passwd = (String) msgContext.getProperty( MessageContext.PASSWORD );
         Debug.Print( 1, "User: " + userID );
         Debug.Print( 2, "Pass: " + passwd );
   
  
  
  
  1.6       +3 -2      xml-axis/java/src/org/apache/axis/handlers/SimpleAuthorizationHandler.java
  
  Index: SimpleAuthorizationHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/SimpleAuthorizationHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SimpleAuthorizationHandler.java	2001/02/11 22:07:18	1.5
  +++ SimpleAuthorizationHandler.java	2001/02/12 01:11:15	1.6
  @@ -60,6 +60,7 @@
   import org.apache.axis.* ;
   import org.apache.axis.utils.* ;
   import org.apache.axis.message.* ;
  +import org.apache.axis.transport.http.HTTPConstants;
   
   /**
    * Just a simple Authorization Handler to see if the user
  @@ -76,8 +77,8 @@
     public void invoke(MessageContext msgContext) throws AxisFault {
       Debug.Print( 1, "Enter: SimpleAuthenticationHandler::invoke" );
       try {
  -      String  userID = (String) msgContext.getProperty( Constants.MC_USERID );
  -      String  action = (String) msgContext.getProperty( Constants.MC_HTTP_SOAPACTION );
  +      String  userID = (String) msgContext.getProperty( MessageContext.USERID );
  +      String  action = (String) msgContext.getProperty( HTTPConstants.MC_HTTP_SOAPACTION
);
   
         Debug.Print( 1, "User: " + userID );
         Debug.Print( 1, "Action: " + action );
  
  
  
  1.17      +3 -3      xml-axis/java/src/org/apache/axis/server/SimpleAxisEngine.java
  
  Index: SimpleAxisEngine.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/SimpleAxisEngine.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- SimpleAxisEngine.java	2001/02/11 22:07:20	1.16
  +++ SimpleAxisEngine.java	2001/02/12 01:11:16	1.17
  @@ -115,11 +115,11 @@
           */
           msgContext.setProperty(Constants.SERVICE_REGISTRY, sr);
   
  -        /** We must have a TARGET to continue.  This tells us which Handler to
  +        /** We must have a TARGET_SERVICE to continue.  This tells us which Handler to
           * pull from the registry and call.  The Transport Listener is responsible
           * for making sure this gets set, and if it isn't, we FAIL.
           */
  -        String target = (String) msgContext.getProperty( Constants.MC_TARGET );
  +        String target = (String) msgContext.getProperty( MessageContext.TARGET_SERVICE
);
           if ( target == null )
               throw new AxisFault("Server.NoTargetConfigured",
                   "AxisEngine: Couldn't find a target property in the MessageContext!",
  @@ -135,7 +135,7 @@
           }
   
           // Clear this for the next round of dispatch, if any.
  -        msgContext.clearProperty( Constants.MC_TARGET );
  +        msgContext.clearProperty( MessageContext.TARGET_SERVICE );
   
           h.init();   // ???
           try {
  
  
  
  1.4       +6 -4      xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java
  
  Index: AxisServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AxisServlet.java	2001/02/10 04:39:59	1.3
  +++ AxisServlet.java	2001/02/12 01:11:17	1.4
  @@ -108,13 +108,15 @@
       MessageContext    msgContext = new MessageContext();
       Message           msg        = new Message( req, "ServletRequest" );
   
  +    msgContext.setProperty(MessageContext.TRANS_ID, HTTPConstants.TRANSPORT_ID);
  +    
       msgContext.setIncomingMessage( msg );
       
       /** Set the target which tells the engine where to dispatch.  In the
        * real world, this would probably be gotten from the servlet
        * configuration.
        */
  -    msgContext.setProperty(Constants.MC_TARGET, Constants.SERVLET_TARGET);
  +    msgContext.setProperty(MessageContext.TARGET_SERVICE, Constants.SERVLET_TARGET);
       
   
       /* Save the SOAPAction header in the MessageContext bag - this will */
  @@ -131,7 +133,7 @@
       tmp = (String) req.getHeader( HTTPConstants.HEADER_SOAP_ACTION );
       if ( tmp != null && "".equals(tmp) )
         tmp = req.getContextPath(); // Is this right?
  -    if ( tmp != null ) msgContext.setProperty( Constants.MC_HTTP_SOAPACTION, tmp );
  +    if ( tmp != null ) msgContext.setProperty( HTTPConstants.MC_HTTP_SOAPACTION, tmp );
   
       tmp = (String) req.getHeader( HTTPConstants.HEADER_AUTHORIZATION );
       if ( tmp != null ) tmp = tmp.trim();
  @@ -143,12 +145,12 @@
         i = tmp.indexOf( ':' );
         if ( i == -1 ) user = tmp ;
         else           user = tmp.substring( 0, i);
  -      msgContext.setProperty( Constants.MC_USERID, user );
  +      msgContext.setProperty( MessageContext.USERID, user );
         if ( i != -1 )  {
           String pwd = tmp.substring(i+1);
           if ( pwd != null && pwd.equals("") ) pwd = null ;
           if ( pwd != null )
  -          msgContext.setProperty( Constants.MC_PASSWORD, pwd );
  +          msgContext.setProperty( MessageContext.PASSWORD, pwd );
         }
       }
   
  
  
  
  1.3       +35 -11    xml-axis/java/src/org/apache/axis/transport/http/HTTPConstants.java
  
  Index: HTTPConstants.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/HTTPConstants.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HTTPConstants.java	2001/02/10 04:39:59	1.2
  +++ HTTPConstants.java	2001/02/12 01:11:17	1.3
  @@ -55,16 +55,40 @@
   
   package org.apache.axis.transport.http;
   
  +/**
  + * HTTP protocol and message context constants.
  + *  
  + * @author Doug Davis (dug@us.ibm.com)
  + * @author Jacek Kopecky (jacek@idoox.com)
  + */
   public class HTTPConstants {
  -  // HTTP Stuff
  -  //////////////////////////////////////////////////////////////////////////
  -  public static final String HEADER_POST = "POST";
  -  public static final String HEADER_HOST = "Host";
  -  public static final String HEADER_CONTENT_TYPE = "Content-Type";
  -  public static final String HEADER_CONTENT_TYPE_JMS = "ContentType";
  -  public static final String HEADER_CONTENT_LENGTH = "Content-Length";
  -  public static final String HEADER_CONTENT_LOCATION = "Content-Location";
  -  public static final String HEADER_CONTENT_ID = "Content-ID";
  -  public static final String HEADER_SOAP_ACTION = "SOAPAction";
  -  public static final String HEADER_AUTHORIZATION = "Authorization";
  +    /** The MessageContext transport ID of HTTP.
  +     *  (Maybe this should be more specific, like "http_servlet",
  +     *   whaddya think? - todo by Jacek)
  +     */
  +    public static String TRANSPORT_ID = "http";
  +
  +    public static final String HEADER_POST = "POST";
  +    public static final String HEADER_HOST = "Host";
  +    public static final String HEADER_CONTENT_TYPE = "Content-Type";
  +    public static final String HEADER_CONTENT_TYPE_JMS = "ContentType";
  +    public static final String HEADER_CONTENT_LENGTH = "Content-Length";
  +    public static final String HEADER_CONTENT_LOCATION = "Content-Location";
  +    public static final String HEADER_CONTENT_ID = "Content-ID";
  +    public static final String HEADER_SOAP_ACTION = "SOAPAction";
  +    public static final String HEADER_AUTHORIZATION = "Authorization";
  +    
  +    /** Integer
  +     */
  +    public static String MC_HTTP_STATUS_CODE    = "transport.http.statusCode";
  +
  +    /** String
  +     */
  +    public static String MC_HTTP_STATUS_MESSAGE = "transport.http.statusMessage";
  +
  +    /** String
  +     *  This can be moved to MessageContext.TRANS_SOAPACTION if more transports
  +     *  have it.
  +     */
  +    public static String MC_HTTP_SOAPACTION     = "transport.http.soapAction";
   }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/transport/http/HTTPDispatchHandler.java
  
  Index: HTTPDispatchHandler.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact 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.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.transport.http;
  
  import java.io.* ;
  import java.net.* ;
  import java.util.* ;
  import org.w3c.dom.* ;
  import org.xml.sax.InputSource ;
  import org.apache.xerces.parsers.DOMParser ;
  import org.apache.axis.* ;
  import org.apache.axis.utils.* ;
  import org.apache.axis.message.* ;
  import org.apache.axis.handlers.BasicHandler;
  import org.apache.axis.encoding.Base64 ;
  
  /**
   * This is meant to be used on a SOAP Client to call a SOAP server.
   *
   * @author Doug Davis (dug@us.ibm.com)
   */
  public class HTTPDispatchHandler extends BasicHandler {
    public void invoke(MessageContext msgContext) throws AxisFault {
      Debug.Print( 1, "Enter: HTTPDispatchHandler::invoke" );
      /* Find the service we're invoking so we can grab it's options */
      /***************************************************************/
      String   targetURL = null ;
      Message  outMsg    = null ;
      String   reqEnv    = null ;
  
      targetURL = (String) msgContext.getProperty( MessageContext.TRANS_URL);
      try {
        String   host ;
        int      port = 80 ;
        String   action = (String) msgContext.getProperty( HTTPConstants.MC_HTTP_SOAPACTION
);
        URL      tmpURL        = new URL( targetURL );
        byte[]   buf           = new byte[4097];
        int      rc            = 0 ;
  
        host = tmpURL.getHost();
        if ( (port = tmpURL.getPort()) == -1 ) port = 80;
  
        Socket             sock = null ;
  
        sock    = new Socket( host, port );
        reqEnv  = (String) msgContext.getIncomingMessage().getAs("String");
  
        OutputStream  out  = sock.getOutputStream();
        InputStream   inp  = sock.getInputStream();
        String        otherHeaders = null ;
        String        userID = null ;
        String        passwd = null ;
        
        userID = (String) msgContext.getProperty( MessageContext.USERID );
        passwd = (String) msgContext.getProperty( MessageContext.PASSWORD );
  
        if ( userID != null )
          otherHeaders = HTTPConstants.HEADER_AUTHORIZATION + ": Basic " + 
                         Base64.encode( (userID + ":" + 
                         ((passwd == null) ? "" : passwd) ).getBytes() ) + 
                         "\n" ;
  
        String  header = HTTPConstants.HEADER_POST + " " + 
                           tmpURL.getFile() + " HTTP/1.0\n" +
                         HTTPConstants.HEADER_CONTENT_LENGTH + ": " + 
                                            + reqEnv.length() + "\n" +
                         HTTPConstants.HEADER_CONTENT_TYPE + ": text.xml\n" +
                         (otherHeaders == null ? "" : otherHeaders) + 
                         HTTPConstants.HEADER_SOAP_ACTION + ":" + action + "\n\n" ;
  
        out.write( header.getBytes() );
        out.write( reqEnv.getBytes() );
  
        Debug.Print( 1, "XML sent:" );
        Debug.Print( 1, header );
        Debug.Print( 1, reqEnv );
  
        byte       lastB=0, b ;
        int        len = 0 ;
        int        colonIndex = -1 ;
        Hashtable  headers = new Hashtable();
        String     name, value ;
  
        // Need to add logic for getting the version # and the return code
        // but that's for tomorrow!
  
        for ( ;; ) {
          if ( (b = (byte) inp.read()) == -1 ) break ;
          if ( b != '\r' && b != '\n' ) {
            if ( b == ':' ) colonIndex = len ;
            lastB = (buf[len++] = b);
          }
          else if ( b == '\r' )
            continue ;
          else {
            if ( len == 0 ) break ;
            if ( colonIndex != -1 ) {
              name = new String( buf, 0, colonIndex );
              value = new String( buf, colonIndex+1, len-1-colonIndex );
            }
            else {
              name = new String( buf, 0, len );
              value = "" ;
            }
            Debug.Print( 2, name + value );
            if ( msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE) == null ) {
              // Reader status code
              int start = name.indexOf( ' ' ) + 1 ;
              int end   = name.indexOf( ' ', start ) ;
              rc = Integer.parseInt( name.substring(start, end) );
              msgContext.setProperty( HTTPConstants.MC_HTTP_STATUS_CODE, 
                                      new Integer(rc) );
              msgContext.setProperty( HTTPConstants.MC_HTTP_STATUS_MESSAGE, 
                                      name.substring(end+1));
            }
            else 
              headers.put( name, value );
            len = 0 ;
          }
        }
        if ( b != -1 ) {
          DOMParser  parser = new DOMParser();
          parser.parse( new InputSource( inp ) );
    
          outMsg = new Message( parser.getDocument(), "Document" );
          msgContext.setOutgoingMessage( outMsg );
          if ( Debug.DebugOn(2) ) {
            Debug.Print( 2, "XML received:" );
            Message m = new Message( parser.getDocument(), "Document" );
            Debug.Print( 2, (String) m.getAs( "String" ) );
          }
        }
  
        inp.close();
        out.close();
        sock.close();
      }
      catch( Exception e ) {
        Debug.Print( 1, e );
        if ( !(e instanceof AxisFault) ) e = new AxisFault(e);
        throw (AxisFault) e ;
      } 
      Debug.Print( 1, "Exit: HTTPDispatchHandler::invoke" );
    }
  
    public void undo(MessageContext msgContext) {
      Debug.Print( 1, "Enter: HTTPDispatchHandler::undo" );
      Debug.Print( 1, "Exit: HTTPDispatchHandler::undo" );
    }
  };
  
  
  

Mime
View raw message