axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r550600 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
Date Mon, 25 Jun 2007 20:51:33 GMT
Author: rott
Date: Mon Jun 25 13:51:32 2007
New Revision: 550600

URL: http://svn.apache.org/viewvc?view=rev&rev=550600
Log:
Dispatch clients were accepting configuration from client apps, but not calling the configured
handlers.

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java?view=diff&rev=550600&r1=550599&r2=550600
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java
Mon Jun 25 13:51:32 2007
@@ -119,6 +119,20 @@
             MessageContext requestMsgCtx = new MessageContext();
             requestMsgCtx.setEndpointDescription(getEndpointDescription());
             invocationContext.setRequestMessageContext(requestMsgCtx);
+            
+            /*
+             * TODO: review: make sure the handlers are set on the InvocationContext
+             * This implementation of the JAXWS runtime does not use Endpoint, which
+             * would normally be the place to initialize and store the handler list.
+             * In lieu of that, we will have to intialize and store them on the 
+             * InvocationContext.  also see the InvocationContextFactory.  On the client
+             * side, the binding is not yet set when we call into that factory, so the
+             * handler list doesn't get set on the InvocationContext object there.  Thus
+             * we gotta do it here.
+             */
+
+            // be sure to use whatever handlerresolver is registered on the Service
+            invocationContext.setHandlers(getBinding().getHandlerChain());
 
             Message requestMsg = null;
             try {

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java?view=diff&rev=550600&r1=550599&r2=550600
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
Mon Jun 25 13:51:32 2007
@@ -23,14 +23,26 @@
 import java.util.Map;
 import java.util.concurrent.Future;
 
+import javax.xml.namespace.QName;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
 import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Binding;
 import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
 import javax.xml.ws.Response;
+import javax.xml.ws.Service;
 import javax.xml.ws.handler.Handler;
 import javax.xml.ws.handler.HandlerResolver;
 import javax.xml.ws.handler.PortInfo;
 import javax.xml.ws.soap.SOAPFaultException;
 
+import java.io.StringReader;
+import java.io.StringWriter;
 import junit.framework.TestCase;
 
 import org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersClientLogicalHandler;
@@ -89,6 +101,44 @@
 		}
 	}
     
+    public void testAddNumbersHandlerDispatch() {
+        try {
+            QName serviceName =
+                    new QName("http://org/test/addnumbershandler", "AddNumbersHandlerService");
+            QName portName =
+                    new QName("http://org/test/addnumbershandler", "AddNumbersHandlerPort");
+
+            Service myService = Service.create(serviceName);
+            myService.addPort(portName, null, axisEndpoint);
+            Dispatch<Source> myDispatch = myService.createDispatch(portName, Source.class,
Service.Mode.PAYLOAD);
+
+            // set handler chain for binding provider
+            Binding binding = ((BindingProvider) myDispatch).getBinding();
+
+            // create a new list or use the existing one
+            List<Handler> handlers = binding.getHandlerChain();
+        
+            if (handlers == null)
+                handlers = new ArrayList<Handler>();
+            handlers.add(new AddNumbersClientLogicalHandler());
+            handlers.add(new AddNumbersClientProtocolHandler());
+            binding.setHandlerChain(handlers);
+            
+            //Invoke the Dispatch
+            TestLogger.logger.debug(">> Invoking Async Dispatch");
+            Source response = myDispatch.invoke(createRequestSource());
+            String resString = getString(response);
+            if (!resString.contains("<return>16</return>")) {
+                fail("Response string should contain <return>17</return>, but
does not.  The resString was: \"" + resString + "\"");
+            }
+
+            TestLogger.logger.debug("----------------------------------");
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail();
+        }
+    }
+    
     /*
      * JAXWS 9.2.1.1 conformance test
      */
@@ -146,7 +196,15 @@
         }
         TestLogger.logger.debug("----------------------------------");
     }
-    
+
+
+    /**
+     * testAddNumbersClientHandler performs the same tests as testAddNumbersHandler, except
+     * that two client-side handlers are also inserted into the flow.  The inbound AddNumbersClientLogicalHandler
+     * checks that the properties set here in this method (the client app) and the properties
set in the
+     * outbound AddNumbersClientProtocolHandler are accessible.  These properties are also
checked here in
+     * the client app.  AddNumbersClientLogicalHandler also subtracts 1 from the sum on the
inbound flow.
+     */
     public void testAddNumbersClientHandler() {
         try{
             TestLogger.logger.debug("----------------------------------");
@@ -295,7 +353,12 @@
             assertEquals(((SOAPFaultException)e).getMessage(), "I don't like the value 99");
         }
     }
-    
+
+    /**
+     * test results should be the same as testAddNumbersClientHandler, except that
+     * AddNumbersClientLogicalHandler2 doubles the first param on outbound.  Async, of course.
+     *
+     */
     public void testAddNumbersClientHandlerAsync() {
         try{
             TestLogger.logger.debug("----------------------------------");
@@ -394,7 +457,36 @@
             handlers.add(new AddNumbersClientProtocolHandler());
             return handlers;
         }
-        
+
     }
     
+    private String getString(Source source) throws Exception {
+        if (source == null) {
+            return null;
+        }
+        StringWriter writer = new StringWriter();
+        Transformer t = TransformerFactory.newInstance().newTransformer();
+        Result result = new StreamResult(writer);
+        t.transform(source, result);
+        return writer.getBuffer().toString();
+
+    }
+    
+    /**
+     * Create a Source request to be used by Dispatch<Source>
+     */
+    private Source createRequestSource() {
+
+        String reqString = null;
+
+        String ns = "http://org/test/addnumbershandler";
+        String operation = "addNumbersHandler";
+
+        reqString = "<" + operation + 
+                    " xmlns=\"" + ns + "\">" +
+                    "<arg0>10</arg0><arg1>10</arg1>" +
+                    "</" + operation + ">";
+
+        return new StreamSource(new StringReader(reqString));
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message