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 Service.java TestSerializedRPC.java
Date Wed, 08 Aug 2001 19:52:54 GMT
rubys       01/08/08 12:52:54

  Modified:    java/src/org/apache/axis/encoding SerializationContext.java
               java/test/RPCDispatch Service.java TestSerializedRPC.java
  Log:
  Ensure that no detectable changes are made to the request in conversion
  to a DOM.  Notes:
  1) pretty indenting of requests and responses are temporarily disabled as
     they use a common mechanism.
  2) As RPCParams are not MessageElements, one can't getAsDOM them.  Pity.
  
  Revision  Changes    Path
  1.30      +8 -5      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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- SerializationContext.java	2001/08/08 18:48:59	1.29
  +++ SerializationContext.java	2001/08/08 19:52:54	1.30
  @@ -78,6 +78,7 @@
   public class SerializationContext
   {
       private static final boolean DEBUG_LOG = false;
  +    private static final boolean pretty = false;
       
       public NSStack nsStack = new NSStack();
                                           
  @@ -310,11 +311,12 @@
           }
           
           if (writingStartTag) {
  -            writer.write(">\n");
  +            writer.write(">");
  +            if (pretty) writer.write(">\n");
               indent++;
           }
           
  -        for (int i=0; i<indent; i++) writer.write(' ');
  +        if (pretty) for (int i=0; i<indent; i++) writer.write(' ');
           StringBuffer buf = new StringBuffer();
           String elementQName = qName2String(qName);
           buf.append("<");
  @@ -361,19 +363,20 @@
           nsStack.peek().clear();
   
           if (writingStartTag) {
  -            writer.write("/>\n");
  +            writer.write("/>");
  +            if (pretty) writer.write("/>");
               writingStartTag = false;
               return;
           }
           
           if (onlyXML) {
             indent--;
  -          for (int i=0; i<indent; i++) writer.write(' ');
  +          if (pretty) for (int i=0; i<indent; i++) writer.write(' ');
           }
           writer.write("</");
           writer.write(elementQName);
           writer.write('>');
  -        if (indent>0) writer.write('\n');
  +        if (pretty) if (indent>0) writer.write('\n');
           writer.flush();
           onlyXML=true;
       }
  
  
  
  1.5       +26 -0     xml-axis/java/test/RPCDispatch/Service.java
  
  Index: Service.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/RPCDispatch/Service.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Service.java	2001/07/17 14:08:32	1.4
  +++ Service.java	2001/08/08 19:52:54	1.5
  @@ -1,6 +1,12 @@
   package test.RPCDispatch;
   
  +import org.apache.axis.message.RPCElement;
  +import org.apache.axis.message.RPCParam;
  +import org.apache.axis.Message;
   import org.apache.axis.MessageContext;
  +import org.apache.axis.utils.DOM2Writer;
  +import org.w3c.dom.Node;
  +import org.w3c.dom.NodeList;
   
   /**
    * Test WebService
  @@ -32,6 +38,26 @@
        */
       public String targetService(MessageContext mc) throws Exception {
          return mc.getTargetService();
  +    }
  +
  +    /**
  +     * Return the target service (should be this!)
  +     */
  +    public String argAsDOM(MessageContext mc, Data input) throws Exception {
  +
  +       // get the first parameter
  +       Message message = mc.getRequestMessage();
  +       RPCElement body = (RPCElement)message.getAsSOAPEnvelope().getFirstBody();
  +       NodeList parms = body.getAsDOM().getChildNodes();
  +       Node parm1 = null;
  +       for (int i=0; i<parms.getLength(); i++) {
  +           parm1 = parms.item(i);
  +           if (parm1.getNodeType() == Node.ELEMENT_NODE) break;
  +       }
  +
  +       // convert it to a DOM and back to a string, and return the result.
  +       return DOM2Writer.nodeToString(parm1, true);
  +
       }
   
       /**
  
  
  
  1.6       +20 -1     xml-axis/java/test/RPCDispatch/TestSerializedRPC.java
  
  Index: TestSerializedRPC.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/RPCDispatch/TestSerializedRPC.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestSerializedRPC.java	2001/08/07 18:58:48	1.5
  +++ TestSerializedRPC.java	2001/08/08 19:52:54	1.6
  @@ -50,7 +50,7 @@
           // Register the reverseString service
           SOAPService reverse = new SOAPService(RPCDispatcher, "RPCDispatcher");
           reverse.addOption("className", "test.RPCDispatch.Service");
  -        reverse.addOption("methodName", "reverseString reverseData");
  +        reverse.addOption("methodName", "*");
           engine.deployService(SOAPAction, reverse);
           
       }
  @@ -160,6 +160,25 @@
           arg += "</arg0>";
           Data expected = new Data(3, "cba", 5);
           assertEquals(expected, rpc("reverseData", arg, true));
  +    }
  +    
  +    /**
  +     * Test DOM round tripping
  +     */
  +    public void testArgAsDOM() throws Exception {
  +        BeanSerializer ser = new BeanSerializer(Data.class);
  +        DeserializerFactory dSerFactory = BeanSerializer.getFactory();
  +        QName qName = new QName("urn:foo", "Data");
  +        engine.registerTypeMapping(qName, Data.class, dSerFactory,
  +                                   ser);
  +        
  +        // invoke the service and verify the result
  +        String arg = "<arg0 xmlns:foo=\"urn:foo\" xsi:type=\"foo:Data\">";
  +        arg += "<field1>5</field1><field2>abc</field2><field3>3</field3>";
  +        arg += "</arg0>";
  +        
  +        // invoke the service and verify the result
  +        assertEquals(arg, rpc("argAsDOM", arg, false));
       }
       
       public static void main(String args[]) {
  
  
  

Mime
View raw message