axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject cvs commit: xml-axis/java/test/RPCDispatch TestRPC.java
Date Wed, 13 Jun 2001 00:25:46 GMT
rubys       01/06/12 17:25:46

  Modified:    java/src/org/apache/axis MessageContext.java
               java/src/org/apache/axis/message SAXAdapter.java
                        SOAPBodyElement.java ThreadedSAXAdapter.java
               java/test/RPCDispatch TestRPC.java
  Log:
  Cure premature deserialization.
  
  Note: test changed to (1) provide required DeserializationContext and
  (2) set EITHER the methodNS or the SOAPAction, but not both.
  
  Revision  Changes    Path
  1.35      +0 -43     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.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- MessageContext.java	2001/06/12 22:24:08	1.34
  +++ MessageContext.java	2001/06/13 00:25:41	1.35
  @@ -258,50 +258,7 @@
        * service specific input/output/pivot point handlers
        */
       private Handler          serviceHandler ;
  -    private boolean          parsing = false;
  -    public void setParsing(boolean parsing)
  -    {
  -        this.parsing = parsing;
  -    }
  -
       public Handler getServiceHandler() {
  -        Debug.Print(2, "MessageContext:getServiceHandler()");
  -        if (serviceHandler == null) {
  -            if (targetService != null) {
  -                /** This is a bit kludgey for now - what might have
  -                *  happened is that someone set the target service name
  -                *  before the registry was set, or before the service
  -                *  was registered.  So just to make sure, we set it
  -                *  again here and see if that causes the serviceHandler
  -                *  to be set correctly.
  -                */
  -                setTargetService(targetService);
  -            } else if (!parsing) {
  -                // No target service was set.  So here's where we want to
  -                // potentially try to dispatch off the QName of the first
  -                // appropriate <Body> element.  Might also hook this to
  -                // another configurable piece of code to avoid SOAP
  -                // specifics in this class.
  -                SOAPEnvelope env = (SOAPEnvelope)
  -                                    inMessage.getAsSOAPEnvelope();
  -                Vector bodies = env.getBodyElements();
  -                Enumeration e = bodies.elements();
  -                while (e.hasMoreElements()) {
  -                    SOAPBodyElement body = (SOAPBodyElement)
  -                                            e.nextElement();
  -                    /** The algorithm we use here is to find the first
  -                     * element without an ID attribute (assuming that
  -                     * ID'ed attributes are multi-ref encodings).
  -                     */
  -                    if (body.getID() == null) {
  -                        //Debug.Print(2, "Dispatching to body namespace '"
  -                        //            + body.getNamespaceURI() + "'");
  -                        setTargetService(body.getNamespaceURI());
  -                    }
  -                }
  -            }
  -      }
  -      Debug.Print(2, "MessageContext:getServiceHandler() returns " + serviceHandler);
         return( serviceHandler );
       }
       
  
  
  
  1.6       +0 -2      xml-axis/java/src/org/apache/axis/message/SAXAdapter.java
  
  Index: SAXAdapter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SAXAdapter.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SAXAdapter.java	2001/06/01 02:13:25	1.5
  +++ SAXAdapter.java	2001/06/13 00:25:43	1.6
  @@ -32,9 +32,7 @@
       public void parse()
       {
         try {
  -        context.getMessageContext().setParsing(true);
           _parser.parse(inputSource, this);
  -        context.getMessageContext().setParsing(false);
         } catch (Exception e) {
           e.printStackTrace();
         }
  
  
  
  1.2       +15 -0     xml-axis/java/src/org/apache/axis/message/SOAPBodyElement.java
  
  Index: SOAPBodyElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPBodyElement.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SOAPBodyElement.java	2001/04/26 22:53:40	1.1
  +++ SOAPBodyElement.java	2001/06/13 00:25:43	1.2
  @@ -57,6 +57,8 @@
   
   import org.xml.sax.Attributes;
   import org.apache.axis.encoding.DeserializationContext;
  +import org.apache.axis.MessageContext;
  +import org.apache.axis.utils.Debug;
   
   /** A Body element.
    * 
  @@ -68,6 +70,19 @@
                         Attributes attributes, DeserializationContext context)
       {
           super(namespace, localPart, attributes, context);
  +
  +        /** The algorithm we use here is to find the first
  +         * element without an ID attribute (assuming that
  +         * ID'ed attributes are multi-ref encodings).
  +         */
  +        if (getID() == null) {
  +            MessageContext msgContext = context.getMessageContext();
  +            if (msgContext.getServiceHandler() == null) {
  +                Debug.Print(2, "Dispatching to body namespace '",
  +                            namespace, "'");
  +                msgContext.setTargetService(namespace);
  +            }
  +        }
       }
       
       public SOAPBodyElement()
  
  
  
  1.6       +0 -2      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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ThreadedSAXAdapter.java	2001/06/01 02:15:22	1.5
  +++ ThreadedSAXAdapter.java	2001/06/13 00:25:43	1.6
  @@ -31,9 +31,7 @@
           public void run()
           {
               try {
  -                context.getMessageContext().setParsing(true);
                   _parser.parse(inputSource, ThreadedSAXAdapter.this);
  -                context.getMessageContext().setParsing(false);
               } catch (Exception e) {
                   e.printStackTrace();
               }
  
  
  
  1.12      +16 -10    xml-axis/java/test/RPCDispatch/TestRPC.java
  
  Index: TestRPC.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/RPCDispatch/TestRPC.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- TestRPC.java	2001/06/12 15:43:24	1.11
  +++ TestRPC.java	2001/06/13 00:25:45	1.12
  @@ -3,6 +3,7 @@
   import junit.framework.TestCase;
   
   import org.apache.axis.*;
  +import org.apache.axis.encoding.*;
   import org.apache.axis.handlers.soap.*;
   import org.apache.axis.message.*;
   import org.apache.axis.server.*;
  @@ -36,7 +37,6 @@
       private Handler RPCDispatcher;
   
       private String SOAPAction = "urn:reverse";
  -    private String methodNS   = SOAPAction;
   
       public TestRPC(String name) {
           super(name);
  @@ -58,20 +58,26 @@
           throws AxisFault
       {
   
  +        // Create the message context
  +        MessageContext msgContext = new MessageContext(engine);
  +        DeserializationContext deserContext =
  +            new DeserializationContext(null, msgContext);
  +
  +        // Set the dispatch either by SOAPAction or methodNS
  +        String methodNS = null;
  +        if (setService) {
  +            msgContext.setTargetService(SOAPAction);
  +        } else {
  +            methodNS = SOAPAction;
  +        }
  +
           // Construct the soap request
           SOAPEnvelope envelope = new SOAPEnvelope();
  -        RPCElement body = new RPCElement(method);
  -        body.setNamespaceURI(methodNS);
  +        msgContext.setRequestMessage(new Message(envelope));
  +        RPCElement body = new RPCElement(methodNS, method, null, deserContext);
           envelope.addBodyElement(body);
           for (int i=0; i<parms.length; i++) {
               body.addParam(new RPCParam("arg"+i, parms[i]));
  -        }
  -
  -        // Create a message context with the action and message
  -        MessageContext msgContext = new MessageContext(engine);
  -        msgContext.setRequestMessage(new Message(envelope));
  -        if (setService) {
  -            msgContext.setTargetService(SOAPAction);
           }
   
           // Invoke the Axis engine
  
  
  

Mime
View raw message