ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r384699 - in /webservices/axis2/trunk/java/modules: core/conf/ core/src/org/apache/axis2/client/ core/src/org/apache/axis2/deployment/ core/src/org/apache/axis2/transport/ core/src/org/apache/axis2/transport/http/ core/src/org/apache/axis2/...
Date Fri, 10 Mar 2006 04:14:26 GMT
Author: deepal
Date: Thu Mar  9 20:14:24 2006
New Revision: 384699

URL: http://svn.apache.org/viewcvs?rev=384699&view=rev
Log:
-fixing 460 (SO IF user want to give his address for epr generation then he has to add the
following parameter into his transport specification in axis2.xml
<parameter name="hostAddress" locked="false">http://myApp.com/ws</parameter> )
-Added a test case to show the power of server side async support :)

Added:
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/async/
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/async/AsyncMessageReceiver.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/async/AsyncServiceTest.java
Modified:
    webservices/axis2/trunk/java/modules/core/conf/axis2.xml
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/axis2_default.xml
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/TransportListener.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/tcp/TCPServer.java

Modified: webservices/axis2/trunk/java/modules/core/conf/axis2.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/conf/axis2.xml?rev=384699&r1=384698&r2=384699&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/conf/axis2.xml (original)
+++ webservices/axis2/trunk/java/modules/core/conf/axis2.xml Thu Mar  9 20:14:24 2006
@@ -33,39 +33,51 @@
     <!-- ================================================= -->
     <!-- Transport Ins -->
     <!-- ================================================= -->
-    <transportReceiver name="http" class="org.apache.axis2.transport.http.SimpleHTTPServer">
+    <transportReceiver name="http"
+                       class="org.apache.axis2.transport.http.SimpleHTTPServer">
         <parameter name="port" locked="false">6060</parameter>
+        <!--If you want to give your own host address for EPR generation-->
+        <!--uncommet following paramter , and set as you required.-->
+        <!--<parameter name="hostAddress" locked="false">http://myApp.com/ws</parameter>-->
     </transportReceiver>
 
     <!--Uncomment if you want to have SMTP transport support-->
- <!--<transportReceiver name="mail" class="org.apache.axis2.transport.mail.SimpleMailListener">-->
-       <!--<parameter name="transport.mail.pop3.host" locked="false">127.0.0.1</parameter>-->
-       <!--<parameter name="transport.mail.pop3.user" locked="false">axis2</parameter>-->
-       <!--<parameter name="transport.mail.pop3.password" locked="false">axis2</parameter>-->
-       <!--<parameter name="transport.mail.pop3.port" locked="false">110</parameter>-->
-       <!--<parameter name="transport.mail.replyToAddress" locked="false">axis2@127.0.0.1</parameter>-->
-   <!--</transportReceiver>-->
+    <!--<transportReceiver name="mail" class="org.apache.axis2.transport.mail.SimpleMailListener">-->
+    <!--<parameter name="transport.mail.pop3.host" locked="false">127.0.0.1</parameter>-->
+    <!--<parameter name="transport.mail.pop3.user" locked="false">axis2</parameter>-->
+    <!--<parameter name="transport.mail.pop3.password" locked="false">axis2</parameter>-->
+    <!--<parameter name="transport.mail.pop3.port" locked="false">110</parameter>-->
+    <!--<parameter name="transport.mail.replyToAddress" locked="false">axis2@127.0.0.1</parameter>-->
+    <!--</transportReceiver>-->
 
-    <transportReceiver name="tcp" class="org.apache.axis2.transport.tcp.TCPServer">
+    <transportReceiver name="tcp"
+                       class="org.apache.axis2.transport.tcp.TCPServer">
         <parameter name="port" locked="false">6060</parameter>
+        <!--If you want to give your own host address for EPR generation-->
+        <!--uncommet following paramter , and set as you required.-->
+        <!--<parameter name="hostAddress" locked="false">tcp://myApp.com/ws</parameter>-->
     </transportReceiver>
 
     <!--Uncomment this if you want JMS transport support-->
     <!--<transportReceiver name="jms" class="org.apache.axis2.transport.jms.SimpleJMSListener">-->
-        <!--<parameter name="transport.jms.Destination" locked="false">dynamicQueues/FOO</parameter>-->
-        <!--<parameter name="java.naming.factory.initial" locked="false">-->
-            <!--org.activemq.jndi.ActiveMQInitialContextFactory</parameter>-->
-        <!--<parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>-->
+    <!--<parameter name="transport.jms.Destination" locked="false">dynamicQueues/FOO</parameter>-->
+    <!--<parameter name="java.naming.factory.initial" locked="false">-->
+    <!--org.activemq.jndi.ActiveMQInitialContextFactory</parameter>-->
+    <!--<parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>-->
     <!--</transportReceiver>-->
 
     <!-- ================================================= -->
     <!-- Transport Outs -->
     <!-- ================================================= -->
 
-    <transportSender name="tcp" class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
-    <transportSender name="local" class="org.apache.axis2.transport.local.LocalTransportSender"/>
-    <transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender"/>
-    <transportSender name="http" class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+    <transportSender name="tcp"
+                     class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
+    <transportSender name="local"
+                     class="org.apache.axis2.transport.local.LocalTransportSender"/>
+    <transportSender name="jms"
+                     class="org.apache.axis2.transport.jms.JMSSender"/>
+    <transportSender name="http"
+                     class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
         <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
         <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
     </transportSender>

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java?rev=384699&r1=384698&r2=384699&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java
Thu Mar  9 20:14:24 2006
@@ -420,28 +420,16 @@
             // and wait on the callbck
             sendReceiveNonBlocking(operation, elem, callback);
             long timeout = options.getTimeOutInMilliSeconds();
-            if (timeout < 0) {
-                while (!callback.isComplete()) {
-                    try {
-                        Thread.sleep(100);
-                    } catch (InterruptedException e) {
-                        throw new AxisFault(e);
-                    }
+            long startTime = System.currentTimeMillis();
+            long currentTime;
+            while (true) {
+                if (callback.isComplete()) {
+                    break;
                 }
-            } else {
-                long index = timeout / 100;
-                while (!callback.isComplete()) {
-                    // wait till the reponse arrives
-                    if (index-- >= 0) {
-                        try {
-                            Thread.sleep(100);
-                        } catch (InterruptedException e) {
-                            throw new AxisFault(e);
-                        }
-                    } else {
-                        throw new AxisFault(Messages
-                                .getMessage("responseTimeOut"));
-                    }
+                currentTime = System.currentTimeMillis();
+                if (currentTime - startTime > timeout) {
+                    throw new AxisFault(Messages
+                            .getMessage("responseTimeOut"));
                 }
             }
             // process the resule of the invocation

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/axis2_default.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/axis2_default.xml?rev=384699&r1=384698&r2=384699&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/axis2_default.xml
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/axis2_default.xml
Thu Mar  9 20:14:24 2006
@@ -31,24 +31,36 @@
     <transportReceiver name="http"
                        class="org.apache.axis2.transport.http.SimpleHTTPServer">
         <parameter name="port" locked="false">6060</parameter>
+        <!--If you want to give your own host address for EPR generation-->
+        <!--uncommet following paramter , and set as you required.-->
+        <!--<parameter name="hostAddress" locked="false">http://myApp.com/ws</parameter>-->
     </transportReceiver>
 
-    <transportReceiver name="tcp"  class="org.apache.axis2.transport.tcp.TCPServer">
+    <transportReceiver name="tcp"
+                       class="org.apache.axis2.transport.tcp.TCPServer">
         <parameter name="port" locked="false">6061</parameter>
+        <!--If you want to give your own host address for EPR generation-->
+        <!--uncommet following paramter , and set as you required.-->
+        <!--<parameter name="hostAddress" locked="false">tcp://myApp.com/ws</parameter>-->
     </transportReceiver>
 
     <!-- ================================================= -->
     <!-- Transport Outs -->
     <!-- ================================================= -->
 
-    <transportSender name="tcp" class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
-    <transportSender name="local" class="org.apache.axis2.transport.local.LocalTransportSender"/>
-    <transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender"/>
-    <transportSender name="http" class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+    <transportSender name="tcp"
+                     class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
+    <transportSender name="local"
+                     class="org.apache.axis2.transport.local.LocalTransportSender"/>
+    <transportSender name="jms"
+                     class="org.apache.axis2.transport.jms.JMSSender"/>
+    <transportSender name="http"
+                     class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
         <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
         <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
     </transportSender>
-    <transportSender name="https" class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+    <transportSender name="https"
+                     class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
         <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
         <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
     </transportSender>

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/TransportListener.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/TransportListener.java?rev=384699&r1=384698&r2=384699&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/TransportListener.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/TransportListener.java
Thu Mar  9 20:14:24 2006
@@ -26,7 +26,9 @@
  * Class TransportListener
  */
 public interface TransportListener {
+
     public static final String PARAM_PORT = "port";
+    public static final String HOST_ADDRESS="hostAddress";
 
     void init(ConfigurationContext axisConf, TransportInDescription transprtIn)
             throws AxisFault;

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java?rev=384699&r1=384698&r2=384699&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java
Thu Mar  9 20:14:24 2006
@@ -62,6 +62,7 @@
     private ThreadFactory threadPool = null;
 
     public static int DEFAULT_PORT = 8080;
+    private String hostAddress = null;
 
     /**
      * Field systemContext
@@ -123,6 +124,10 @@
             if (param != null) {
                 this.port = Integer.parseInt((String) param.getValue());
             }
+            param = transprtIn.getParameter(HOST_ADDRESS);
+            if (param != null) {
+                hostAddress = ((String) param.getValue()).trim();
+            }
         } catch (Exception e1) {
             throw new AxisFault(e1);
         }
@@ -212,6 +217,9 @@
 
     /**
      * replyToEPR
+     * If the user has given host address paramter then it gets the high priority and
+     * ERP will be creatd using that
+     * N:B - hostAddress should be a complte url (http://www.myApp.com/ws)
      *
      * @param serviceName
      * @param ip
@@ -219,18 +227,28 @@
      * @see org.apache.axis2.transport.TransportListener#getEPRForService(String,String)
      */
     public EndpointReference getEPRForService(String serviceName, String ip) throws AxisFault
{
-        String hostAddress;
+        //if host address is present
+        if (hostAddress != null) {
+            if (embedded != null) {
+                return new EndpointReference(hostAddress + "/axis2/services/" + serviceName);
+            } else {
+                throw new AxisFault("Unable to generate EPR for the transport : http");
+            }
+        }
+        //if the host address is not present
+        String localAddress;
         if (ip != null) {
-            hostAddress = ip;
+            localAddress = ip;
         } else {
             try {
-                hostAddress = SimpleHttpServerConnection.getIpAddress();
+                localAddress = SimpleHttpServerConnection.getIpAddress();
             } catch (SocketException e) {
                 throw AxisFault.makeFault(e);
             }
         }
         if (embedded != null) {
-            return new EndpointReference("http://" + hostAddress + ":" + (embedded.getLocalPort())
+            return new EndpointReference("http://" + localAddress + ":" +
+                    (embedded.getLocalPort())
                     + "/axis2/services/" + serviceName);
         } else {
             throw new AxisFault("Unable to generate EPR for the transport : http");

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/tcp/TCPServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/tcp/TCPServer.java?rev=384699&r1=384698&r2=384699&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/tcp/TCPServer.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/tcp/TCPServer.java
Thu Mar  9 20:14:24 2006
@@ -48,6 +48,7 @@
     protected Log log = LogFactory.getLog(SimpleHTTPServer.class.getName());
     private ConfigurationContext configContext;
     private ServerSocket serversocket;
+    private String hostAddress = null;
 
     public TCPServer() {
     }
@@ -86,6 +87,10 @@
         if (param != null) {
             this.port = Integer.parseInt((String) param.getValue());
         }
+        param = transprtIn.getParameter(HOST_ADDRESS);
+        if (param != null) {
+            hostAddress = ((String) param.getValue()).trim();
+        }
     }
 
     public static void main(String[] args) throws AxisFault, NumberFormatException {
@@ -169,11 +174,24 @@
         return this.configContext;
     }
 
-    /*
-     *  (non-Javadoc)
-     * @see org.apache.axis2.transport.TransportListener#replyToEPR(java.lang.String)
+    /**
+     * I fthe hostAddress parameter is present in axis2.xml then the EPR will be
+     * created by taking the hostAddres into account
+     * (non-Javadoc)
+     *
+     * @see org.apache.axis2.transport.TransportListener#replyToEPR(String)
      */
     public EndpointReference getEPRForService(String serviceName, String ip) throws AxisFault
{
+        //if host address is present
+        if (hostAddress != null) {
+            if (serversocket != null) {
+                // todo this has to fix
+                return new EndpointReference(hostAddress + "/axis2/services/" + serviceName);
+            } else {
+                log.info("Unable to generate EPR for the transport tcp");
+                return null;
+            }
+        }
         if (ip == null) {
             try {
                 ip = SimpleHttpServerConnection.getIpAddress();

Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/async/AsyncMessageReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/async/AsyncMessageReceiver.java?rev=384699&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/async/AsyncMessageReceiver.java
(added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/async/AsyncMessageReceiver.java
Thu Mar  9 20:14:24 2006
@@ -0,0 +1,108 @@
+package org.apache.axis2.async;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.DependencyManager;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.receivers.AbstractInOutAsyncMessageReceiver;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.soap.SOAPEnvelope;
+import org.apache.ws.commons.soap.SOAPFactory;
+
+import java.lang.reflect.Method;
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*
+*/
+
+public class AsyncMessageReceiver extends AbstractInOutAsyncMessageReceiver {
+
+    public void invokeBusinessLogic(MessageContext msgContext,
+                                    MessageContext newmsgContext) throws AxisFault {
+        try {
+            //TODO : I know this is wrong , but I have to spend time here
+            System.out.println(" ****************** Request received *****************");
+            Thread.sleep(40000);
+            System.out.println(" **********Started to process the requset**************");
+            // get the implementation class for the Web Service
+            Object obj = getTheImplementationObject(msgContext);
+
+            // find the WebService method
+            Class ImplClass = obj.getClass();
+
+            // Inject the Message Context if it is asked for
+            DependencyManager.configureBusinessLogicProvider(obj, msgContext, newmsgContext);
+
+            AxisOperation opDesc = msgContext.getOperationContext().getAxisOperation();
+            Method method = findOperation(opDesc, ImplClass);
+
+            if (method != null) {
+                Class[]  parameters = method.getParameterTypes();
+                Object[] args;
+
+                if ((parameters == null) || (parameters.length == 0)) {
+                    args = new Object[0];
+                } else if (parameters.length == 1) {
+                    OMElement omElement = msgContext.getEnvelope().getBody().getFirstElement();
+                    args = new Object[]{omElement};
+                } else {
+                    throw new AxisFault(Messages.getMessage("rawXmlProivdeIsLimited"));
+                }
+
+                OMElement result = (OMElement) method.invoke(obj, args);
+                AxisService service = msgContext.getAxisService();
+                service.getTargetNamespace();
+                result.declareNamespace(service.getTargetNamespace(),
+                        service.getTargetNamespacePrefix());
+                OMElement bodyContent;
+
+                SOAPFactory fac = getSOAPFactory(msgContext);
+                bodyContent = result;
+
+                SOAPEnvelope envelope = fac.getDefaultEnvelope();
+
+                if (bodyContent != null) {
+                    envelope.getBody().addChild(bodyContent);
+                }
+
+                newmsgContext.setEnvelope(envelope);
+            } else {
+                throw new AxisFault(Messages.getMessage("methodNotImplemented",
+                        opDesc.getName().toString()));
+            }
+        } catch (Exception e) {
+            throw AxisFault.makeFault(e);
+        }
+    }
+
+    public Method findOperation(AxisOperation op, Class ImplClass) {
+        Method method = null;
+        String methodName = op.getName().getLocalPart();
+        Method[] methods = ImplClass.getMethods();
+
+        for (int i = 0; i < methods.length; i++) {
+            if (methods[i].getName().equals(methodName)) {
+                method = methods[i];
+
+                break;
+            }
+        }
+
+        return method;
+    }
+}

Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/async/AsyncServiceTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/async/AsyncServiceTest.java?rev=384699&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/async/AsyncServiceTest.java
(added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/async/AsyncServiceTest.java
Thu Mar  9 20:14:24 2006
@@ -0,0 +1,140 @@
+package org.apache.axis2.async;
+
+import junit.framework.TestCase;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.client.async.AsyncResult;
+import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.Echo;
+import org.apache.axis2.engine.util.TestConstants;
+import org.apache.axis2.integration.TestingUtils;
+import org.apache.axis2.integration.UtilServer;
+import org.apache.axis2.util.Utils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.commons.om.OMAbstractFactory;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMFactory;
+import org.apache.ws.commons.om.OMNamespace;
+
+import javax.xml.namespace.QName;
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*
+*/
+
+public class AsyncServiceTest extends TestCase implements TestConstants {
+
+    protected Log log = LogFactory.getLog(getClass());
+    protected QName transportName = new QName("http://localhost/my",
+            "NullTransport");
+    EndpointReference targetEPR = new EndpointReference(
+            "http://127.0.0.1:" + (UtilServer.TESTING_PORT)
+//            "http://127.0.0.1:" + 5556
+                    + "/axis2/services/EchoXMLService/echoOMElement");
+
+    protected AxisConfiguration engineRegistry;
+    protected MessageContext mc;
+    protected ServiceContext serviceContext;
+    protected AxisService service;
+    private boolean finish = false;
+
+    protected void setUp() throws Exception {
+        UtilServer.start();
+        service = Utils.createSimpleService(serviceName,
+                new AsyncMessageReceiver(),
+                Echo.class.getName(),
+                operationName);
+        UtilServer.deployService(service);
+    }
+
+    protected void tearDown() throws Exception {
+        UtilServer.unDeployService(serviceName);
+        UtilServer.stop();
+        UtilServer.unDeployClientService();
+    }
+
+    public void testEchoXMLCompleteASync() throws Exception {
+        AxisService service =
+                Utils.createSimpleServiceforClient(serviceName,
+                        Echo.class.getName(),
+                        operationName);
+
+        ConfigurationContext configcontext = UtilServer.createClientConfigurationContext();
+
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+
+        OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
+        OMElement method = fac.createOMElement("echoOMElement", omNs);
+        OMElement value = fac.createOMElement("myValue", omNs);
+        value.setText("Isaac Asimov, The Foundation Trilogy");
+        method.addChild(value);
+        ServiceClient sender = null;
+
+        try {
+            Options options = new Options();
+            options.setTo(targetEPR);
+            options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+            options.setUseSeparateListener(true);
+            options.setAction(operationName.getLocalPart());
+
+            Callback callback = new Callback() {
+                public void onComplete(AsyncResult result) {
+                    TestingUtils.campareWithCreatedOMElement(
+                            result.getResponseEnvelope().getBody()
+                                    .getFirstElement());
+                    System.out.println("result = " + result.getResponseEnvelope().getBody()
+                                    .getFirstElement());
+                    finish = true;
+                }
+
+                public void onError(Exception e) {
+                    log.info(e.getMessage());
+                    finish = true;
+                }
+            };
+
+            sender = new ServiceClient(configcontext, service);
+            sender.setOptions(options);
+
+            sender.sendReceiveNonBlocking(operationName, method, callback);
+            System.out.println("send the reqest");
+            log.info("send the reqest");
+            int index = 0;
+            while (!finish) {
+                Thread.sleep(1000);
+                index++;
+                if (index > 42) {
+                    throw new AxisFault(
+                            "Server was shutdown as the async response take too long to complete");
+                }
+            }
+        } finally {
+            if (sender != null)
+                sender.finalizeInvoke();
+        }
+
+    }
+
+}



Mime
View raw message