Author: chamikara
Date: Sun Feb 26 09:36:22 2006
New Revision: 381126

URL: http://svn.apache.org/viewcvs?rev=381126&view=rev
Log:
Changed the interop sample to go with the requirement of the new WSRM spec.

Modified:
    
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/AsyncEchoClient.java
    
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/AsyncPingClient.java
    
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/RMInteropService.java
    
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/SyncEchoClient.java
    
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/SyncPingClient.java

Modified: 
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/AsyncEchoClient.java
URL: 
http://svn.apache.org/viewcvs/webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/AsyncEchoClient.java?rev=381126&r1=381125&r2=381126&view=diff
==============================================================================
--- 
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/AsyncEchoClient.java
 (original)
+++ 
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/AsyncEchoClient.java
 Sun Feb 26 09:36:22 2006
@@ -22,7 +22,6 @@
 
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.client.Call;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.client.async.AsyncResult;
@@ -30,19 +29,22 @@
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.context.MessageContextConstants;
-import org.apache.axis2.description.AxisService;
+import org.apache.sandesha2.client.Sandesha2ClientAPI;
 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 org.apache.ws.commons.soap.SOAP12Constants;
-import org.apache.sandesha2.Sandesha2Constants;
-import org.apache.sandesha2.client.RMReport;
-import org.apache.sandesha2.client.Sandesha2ClientAPI;
-import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.ws.commons.soap.SOAPBody;
 
 public class AsyncEchoClient {
        
+       private final static String applicationNamespaceName = 
"http://tempuri.org/";; 
+       private final static String echoString = "echoString";
+       private final static String Text = "Text";
+       private final static String Sequence = "Sequence";
+       private final static String echoStringResponse = "echoStringResponse";
+       private final static String EchoStringReturn = "EchoStringReturn";
+       
        private String toIP = "127.0.0.1";
        
        private String ackIP = "127.0.0.1";
@@ -95,16 +97,19 @@
                clientOptions.setProperty(Options.COPY_PROPERTIES,new Boolean 
(true));
                clientOptions.setTo(new EndpointReference (toEPR));
                clientOptions.setProperty(Sandesha2ClientAPI.AcksTo,acksToEPR);
-               
clientOptions.setProperty(Sandesha2ClientAPI.SEQUENCE_KEY,"sequence1");
+               
+               String sequenceKey = "sequence4";
+               
clientOptions.setProperty(Sandesha2ClientAPI.SEQUENCE_KEY,sequenceKey);
+               
                
clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
                
-               
//clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);
   //uncomment this to send messages without chunking.
+//             
clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);
   //uncomment this to send messages without chunking.
                
-               
//clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); 
  //uncomment this to send messages in SOAP 1.2
+//             
clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);   
//uncomment this to send messages in SOAP 1.2
                
-               
//clientOptions.setProperty(Sandesha2ClientAPI.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.WSRX);
  //uncomment this to send the messages according to the WSRX spec.
+//             
clientOptions.setProperty(Sandesha2ClientAPI.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.WSRX);
  //uncomment this to send the messages according to the WSRX spec.
                
-               
//clientOptions.setProperty(Sandesha2ClientAPI.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID());
  //Uncomment this to offer a sequenceID for the incoming sequence.
+//             
clientOptions.setProperty(Sandesha2ClientAPI.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID());
  //Uncomment this to offer a sequenceID for the incoming sequence.
                
                //You must set the following two properties in the 
request-reply case.
                clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
@@ -114,34 +119,39 @@
                serviceClient.engageModule(new QName ("sandesha2"));  
//engaging the sandesha2 module.
                
                Callback callback1 = new TestCallback ("Callback 1");
-               
serviceClient.sendReceiveNonblocking(getEchoOMBlock("echo1"),callback1);
-               Callback callback2 = new TestCallback ("Callback 2");
-               
serviceClient.sendReceiveNonblocking(getEchoOMBlock("echo2"),callback2);
+               
serviceClient.sendReceiveNonblocking(getEchoOMBlock("echo1",sequenceKey),callback1);
                
+               Callback callback2 = new TestCallback ("Callback 2");
+               
serviceClient.sendReceiveNonblocking(getEchoOMBlock("echo2",sequenceKey),callback2);
+
                Callback callback3 = new TestCallback ("Callback 3");
-               
serviceClient.sendReceiveNonblocking(getEchoOMBlock("echo3"),callback3);
+               
serviceClient.sendReceiveNonblocking(getEchoOMBlock("echo3",sequenceKey),callback3);
+               
                Callback callback4 = new TestCallback ("Callback 4");
-               
serviceClient.sendReceiveNonblocking(getEchoOMBlock("echo4"),callback4);
+               
serviceClient.sendReceiveNonblocking(getEchoOMBlock("echo4",sequenceKey),callback4);
                
                clientOptions.setProperty(Sandesha2ClientAPI.LAST_MESSAGE, 
"true");
-               Callback callback5 = new TestCallback ("Callback 6");
-               
serviceClient.sendReceiveNonblocking(getEchoOMBlock("echo6"),callback5);
+               Callback callback5 = new TestCallback ("Callback 5");
+               
serviceClient.sendReceiveNonblocking(getEchoOMBlock("echo5",sequenceKey),callback5);
                
         while (!callback5.isComplete()) {
             Thread.sleep(1000);
         }
-       
        }
 
-       private static OMElement getEchoOMBlock(String text) {
+       private static OMElement getEchoOMBlock(String text, String 
sequenceKey) {
                OMFactory fac = OMAbstractFactory.getOMFactory();
-               OMNamespace defaultNS = 
fac.createOMNamespace("http://tempuri.apache.org","ns1";);
-               OMElement echoElement = fac.createOMElement("echoString", null);
-               OMElement paramElement = fac.createOMElement("text", null);
-               echoElement.addChild(paramElement);
-               paramElement.setText(text);
-
-               return echoElement;
+               OMNamespace applicationNamespace = 
fac.createOMNamespace(applicationNamespaceName,"ns1");
+               OMElement echoStringElement = fac.createOMElement(echoString, 
applicationNamespace);
+               OMElement textElem = 
fac.createOMElement(Text,applicationNamespace);
+               OMElement sequenceElem = 
fac.createOMElement(Sequence,applicationNamespace);
+               
+               textElem.setText(text);
+               sequenceElem.setText(sequenceKey);
+               echoStringElement.addChild(textElem);
+               echoStringElement.addChild(sequenceElem);
+               
+               return echoStringElement;
        }
 
        class TestCallback extends Callback {
@@ -154,24 +164,22 @@
                
                public void onComplete(AsyncResult result) {
                        //System.out.println("On Complete Called for " + text);
-                       OMElement responseElement = 
result.getResponseEnvelope().getBody().getFirstElement();
-                       if (responseElement==null) {
-                               System.out.println("Response element is null");
+                       SOAPBody body = result.getResponseEnvelope().getBody();
+                       
+                       OMElement echoStringResponseElem = 
body.getFirstChildWithName(new QName 
(applicationNamespaceName,echoStringResponse));
+                       if (echoStringResponseElem==null) { 
+                               System.out.println("Error: SOAPBody does not 
have a 'echoStringResponse' child");
                                return;
                        }
                        
-                       String tempText = responseElement.getText();
-                       if (tempText==null || "".equals(tempText)){
-                               OMElement child = 
responseElement.getFirstElement();
-                               if (child!=null)
-                                       tempText = child.getText();
+                       OMElement echoStringReturnElem = 
echoStringResponseElem.getFirstChildWithName(new QName 
(applicationNamespaceName,EchoStringReturn));
+                       if (echoStringReturnElem==null) { 
+                               System.out.println("Error: 'echoStringResponse' 
element does not have a 'EchoStringReturn' child");
+                               return;
                        }
                        
-                       
-                       tempText = (tempText==null)?"":tempText;
-                       
-                       System.out.println("Callback '" + name +  "' got 
result:" + tempText);
-                       
+                       String resultStr = echoStringReturnElem.getText();
+                       System.out.println("Callback '" + name +  "' got 
result:" + resultStr);
                }
 
                public void onError (Exception e) {

Modified: 
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/AsyncPingClient.java
URL: 
http://svn.apache.org/viewcvs/webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/AsyncPingClient.java?rev=381126&r1=381125&r2=381126&view=diff
==============================================================================
--- 
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/AsyncPingClient.java
 (original)
+++ 
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/AsyncPingClient.java
 Sun Feb 26 09:36:22 2006
@@ -23,24 +23,23 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.client.MessageSender;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.axis2.context.MessageContextConstants;
-import org.apache.axis2.description.AxisService;
+import org.apache.sandesha2.client.Sandesha2ClientAPI;
 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 org.apache.ws.commons.soap.SOAP12Constants;
-import org.apache.sandesha2.Sandesha2Constants;
-import org.apache.sandesha2.client.Sandesha2ClientAPI;
 
 
 public class AsyncPingClient {
 
+       private static final String applicationNamespaceName = 
"http://tempuri.org/";; 
+       private static final String Ping = "Ping";
+       private static final String Text = "Text";
+       
        private String toIP = "127.0.0.1";
        
        private String toPort = "8070";
@@ -84,17 +83,17 @@
                
                Options clientOptions = new Options ();
                
-               
//clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);
   //uncomment this to send messages without chunking.
+//             
clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);
   //uncomment this to send messages without chunking.
                
-               
//clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); 
  //uncomment this to send messages in SOAP 1.2
+//             
clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);   
//uncomment this to send messages in SOAP 1.2
                
-               
//clientOptions.setProperty(Sandesha2ClientAPI.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.WSRX);
  //uncomment this to send the messages according to the WSRX spec.
+//             
clientOptions.setProperty(Sandesha2ClientAPI.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.WSRX);
  //uncomment this to send the messages according to the WSRX spec.
                
                clientOptions.setProperty(Options.COPY_PROPERTIES,new Boolean 
(true));
                clientOptions.setTo(new EndpointReference (toEPR));
                clientOptions.setProperty(Sandesha2ClientAPI.AcksTo,acksToEPR);
                clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-               
clientOptions.setProperty(Sandesha2ClientAPI.SEQUENCE_KEY,"sequence1");
+               
clientOptions.setProperty(Sandesha2ClientAPI.SEQUENCE_KEY,"sequence2");
                
                serviceClient.setOptions(clientOptions);
                serviceClient.engageModule(new QName ("sandesha2"));
@@ -109,14 +108,14 @@
        
        private static OMElement getPingOMBlock(String text) {
                OMFactory fac = OMAbstractFactory.getOMFactory();
-               OMNamespace ns = 
fac.createOMNamespace("http://tempuri.apache.org";,
-                               "ns1");
-               OMElement pingElement = fac.createOMElement("ping", ns);
-               OMElement paramElement = fac.createOMElement("param1", ns);
-               pingElement.addChild(paramElement);
-               paramElement.setText(text);
+               OMNamespace namespace = 
fac.createOMNamespace(applicationNamespaceName,"ns1");
+               OMElement pingElem = fac.createOMElement(Ping, namespace);
+               OMElement textElem = fac.createOMElement(Text, namespace);
+               
+               textElem.setText(text);
+               pingElem.addChild(textElem);
 
-               return pingElement;
+               return pingElem;
        }
        
 }

Modified: 
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/RMInteropService.java
URL: 
http://svn.apache.org/viewcvs/webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/RMInteropService.java?rev=381126&r1=381125&r2=381126&view=diff
==============================================================================
--- 
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/RMInteropService.java
 (original)
+++ 
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/RMInteropService.java
 Sun Feb 26 09:36:22 2006
@@ -20,6 +20,9 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.xml.namespace.QName;
+
+import org.apache.sandesha2.SandeshaException;
 import org.apache.ws.commons.om.OMAbstractFactory;
 import org.apache.ws.commons.om.OMElement;
 import org.apache.ws.commons.om.OMFactory;
@@ -27,104 +30,60 @@
 
 public class RMInteropService {
 
-       private static Map sequences = new HashMap();
-
-       public OMElement echoString(OMElement in) {
-
-               String responseText = null;
-               if (in != null) {
-                       String tempText = in.getText();
-                       if (tempText == null || "".equals(tempText)) {
-                               OMElement firstChild = in.getFirstElement();
-                               if (firstChild != null)
-                                       tempText = firstChild.getText();
-                       }
-
-                       if (tempText != null)
-                               responseText = tempText;
-               }
-
-               System.out.println("echoString got text:"
-                               + ((null == responseText) ? "" : responseText));
+       private static Map sequenceStrings = new HashMap();  //TODO make this 
non static
+       private final String applicationNamespaceName = "http://tempuri.org/";; 
+       private final String Text = "Text";
+       private final String Sequence = "Sequence";
+       private final String echoStringResponse = "echoStringResponse";
+       private final String EchoStringReturn = "EchoStringReturn";
+  
+       public OMElement echoString(OMElement in) throws Exception {
+               
+               OMElement textElem = in.getFirstChildWithName(new QName 
(applicationNamespaceName,Text));
+               OMElement sequenceElem = in.getFirstChildWithName(new QName 
(applicationNamespaceName,Sequence));
+               
+               if (textElem==null)
+                       throw new SandeshaException ("'Text' element is not 
present as a child of the 'echoString' element");
+               if (sequenceElem==null)
+                       throw new SandeshaException ("'Sequence' element is not 
present as a child of the 'echoString' element");
+               
+               String textStr = textElem.getText();
+               String sequenceStr = sequenceElem.getText();
+               
+               System.out.println("'EchoString' service got text '" + textStr 
+ "' for the sequence '" + sequenceStr + "'");
+               
+               String previousText = (String) sequenceStrings.get(sequenceStr);
+               String resultText = 
(previousText==null)?textStr:previousText+textStr;
+               sequenceStrings.put(sequenceStr,resultText);
+               
+               
                OMFactory fac = OMAbstractFactory.getOMFactory();
-               OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/";,
-                               "echoString");
-               OMElement method = fac.createOMElement("echoStringResponse", 
omNs);
-
-               OMElement value = fac.createOMElement("text", omNs);
-
-               if (responseText == null || "".equals(responseText))
-                       responseText = "echo response";
-
-               value.setText(responseText);
-               method.addChild(value);
-
-               return method;
+               OMNamespace applicationNamespace = 
fac.createOMNamespace(applicationNamespaceName,"ns1");
+               OMElement echoStringResponseElem = 
fac.createOMElement(echoStringResponse, applicationNamespace);
+               OMElement echoStringReturnElem = 
fac.createOMElement(EchoStringReturn, applicationNamespace);
+               
+               echoStringReturnElem.setText(resultText);
+               echoStringResponseElem.addChild(echoStringReturnElem);
+               
+               return echoStringResponseElem;
        }
-
-       public void ping(OMElement in) {
-               //Just accept the message and do some processing
-
-               String text = null;
-               if (in != null) {
-                       OMElement firstElement = in.getFirstElement();
-                       if (firstElement != null) {
-                               text = firstElement.getText();
-                       }
-               }
-
-               text = (text == null) ? "" : text;
-
-               System.out.println("Ping got text:" + text);
+  
+       public void ping(OMElement in) throws Exception  {
+               OMElement textElem = in.getFirstChildWithName(new QName 
(applicationNamespaceName,Text));
+               if (textElem==null)
+                       throw new Exception ("'Text' element is not present as 
a child of the 'Ping' element");
+               
+               String textValue = textElem.getText();
+               
+               System.out.println("ping service got text:" + textValue);
        }
 
-       public OMElement EchoString(OMElement in) {
-
-               String responseText = null;
-               if (in != null) {
-                       String tempText = in.getText();
-                       if (tempText == null || "".equals(tempText)) {
-                               OMElement firstChild = in.getFirstElement();
-                               if (firstChild != null)
-                                       tempText = firstChild.getText();
-                       }
-
-                       if (tempText != null)
-                               responseText = tempText;
-               }
-
-               System.out.println("echoString got text:"
-                               + ((null == responseText) ? "" : responseText));
-               OMFactory fac = OMAbstractFactory.getOMFactory();
-               OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/";,
-                               "echoString");
-               OMElement method = fac.createOMElement("echoStringResponse", 
omNs);
-
-               OMElement value = fac.createOMElement("text", omNs);
-
-               if (responseText == null || "".equals(responseText))
-                       responseText = "echo response";
-
-               value.setText(responseText);
-               method.addChild(value);
-
-               return method;
+       public OMElement EchoString(OMElement in) throws Exception  {
+               return echoString(in);
        }
 
-       public void Ping(OMElement in) {
-               //Just accept the message and do some processing
-
-               String text = null;
-               if (in != null) {
-                       OMElement firstElement = in.getFirstElement();
-                       if (firstElement != null) {
-                               text = firstElement.getText();
-                       }
-               }
-
-               text = (text == null) ? "" : text;
-
-               System.out.println("Ping got text:" + text);
+       public void Ping(OMElement in) throws Exception  {
+               ping(in);
        }
 
 }

Modified: 
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/SyncEchoClient.java
URL: 
http://svn.apache.org/viewcvs/webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/SyncEchoClient.java?rev=381126&r1=381125&r2=381126&view=diff
==============================================================================
--- 
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/SyncEchoClient.java
 (original)
+++ 
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/SyncEchoClient.java
 Sun Feb 26 09:36:22 2006
@@ -19,31 +19,31 @@
 import java.io.File;
 
 import javax.xml.namespace.QName;
-
-import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.client.Call;
 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.ConfigurationContextFactory;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
+import org.apache.sandesha2.client.Sandesha2ClientAPI;
 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 org.apache.ws.commons.soap.SOAP12Constants;
-import org.apache.sandesha2.Sandesha2Constants;
-import org.apache.sandesha2.client.Sandesha2ClientAPI;
-import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.ws.commons.soap.SOAPBody;
 
 
 public class SyncEchoClient {
 
+       private final static String applicationNamespaceName = 
"http://tempuri.org/";; 
+       private final static String echoString = "echoString";
+       private final static String Text = "Text";
+       private final static String Sequence = "Sequence";
+       private final static String echoStringResponse = "echoStringResponse";
+       private final static String EchoStringReturn = "EchoStringReturn";
+       
        private String toIP = "127.0.0.1";
        
        private String toPort = "8070";
@@ -83,46 +83,52 @@
                
                clientOptions.setProperty(Options.COPY_PROPERTIES,new Boolean 
(true));
                clientOptions.setTo(new EndpointReference (toEPR));
-               
clientOptions.setProperty(Sandesha2ClientAPI.SEQUENCE_KEY,"sequence1");
+               
+               String sequenceKey = "sequence3";
+               
clientOptions.setProperty(Sandesha2ClientAPI.SEQUENCE_KEY,sequenceKey);
 
                //You must set the following two properties in the 
request-reply case.
                clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
                clientOptions.setUseSeparateListener(true);
                
-               
//clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);
   //uncomment this to send messages without chunking.
+//             
clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);
   //uncomment this to send messages without chunking.
                
-               
//clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); 
  //uncomment this to send messages in SOAP 1.2
+//             
clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);   
//uncomment this to send messages in SOAP 1.2
                
-               
//clientOptions.setProperty(Sandesha2ClientAPI.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.WSRX);
  //uncomment this to send the messages according to the WSRX spec.
+//             
clientOptions.setProperty(Sandesha2ClientAPI.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.WSRX);
  //uncomment this to send the messages according to the WSRX spec.
                
-               
//clientOptions.setProperty(Sandesha2ClientAPI.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID());
  //Uncomment this to offer a sequenceID for the incoming sequence.
+//             
clientOptions.setProperty(Sandesha2ClientAPI.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID());
  //Uncomment this to offer a sequenceID for the incoming sequence.
                
                serviceClient.setOptions(clientOptions);
                serviceClient.engageModule(new QName ("sandesha2"));  
//engaging the sandesha2 module
                
                Callback callback1 = new TestCallback ("Callback 1");
-               
serviceClient.sendReceiveNonblocking(getEchoOMBlock("echo1"),callback1);
+               
serviceClient.sendReceiveNonblocking(getEchoOMBlock("echo1",sequenceKey),callback1);
                Callback callback2 = new TestCallback ("Callback 2");
-               
serviceClient.sendReceiveNonblocking(getEchoOMBlock("echo2"),callback2);
+               
serviceClient.sendReceiveNonblocking(getEchoOMBlock("echo2",sequenceKey),callback2);
                
                clientOptions.setProperty(Sandesha2ClientAPI.LAST_MESSAGE, 
"true");
                Callback callback3 = new TestCallback ("Callback 3");
-               
serviceClient.sendReceiveNonblocking(getEchoOMBlock("echo3"),callback3);
+               
serviceClient.sendReceiveNonblocking(getEchoOMBlock("echo3",sequenceKey),callback3);
                
         while (!callback3.isComplete()) {
             Thread.sleep(1000);
         }
        }
 
-       private static OMElement getEchoOMBlock(String text) {
+       private static OMElement getEchoOMBlock(String text, String 
sequenceKey) {              
                OMFactory fac = OMAbstractFactory.getOMFactory();
-               OMNamespace defaultNS = 
fac.createOMNamespace("http://tempuri.apache.org","ns1";);
-               OMElement echoElement = fac.createOMElement("echoString", 
defaultNS);
-               OMElement paramElement = fac.createOMElement("text", defaultNS);
-               echoElement.addChild(paramElement);
-               paramElement.setText(text);
+               OMNamespace applicationNamespace = 
fac.createOMNamespace(applicationNamespaceName,"ns1");
+               OMElement echoStringElement = fac.createOMElement(echoString, 
applicationNamespace);
+               OMElement textElem = 
fac.createOMElement(Text,applicationNamespace);
+               OMElement sequenceElem = 
fac.createOMElement(Sequence,applicationNamespace);
+               
+               textElem.setText(text);
+               sequenceElem.setText(sequenceKey);
+               echoStringElement.addChild(textElem);
+               echoStringElement.addChild(sequenceElem);
 
-               return echoElement;
+               return echoStringElement;
        }
 
        private class TestCallback extends Callback {
@@ -139,23 +145,22 @@
                
                public void onComplete(AsyncResult result) {
                        //System.out.println("On Complete Called for " + text);
-                       OMElement responseElement = 
result.getResponseEnvelope().getBody().getFirstElement();
-                       if (responseElement==null) {
-                               System.out.println("Response element is null");
+                       SOAPBody body = result.getResponseEnvelope().getBody();
+                       
+                       OMElement echoStringResponseElem = 
body.getFirstChildWithName(new QName 
(applicationNamespaceName,echoStringResponse));
+                       if (echoStringResponseElem==null) { 
+                               System.out.println("Error: SOAPBody does not 
have a 'echoStringResponse' child");
                                return;
                        }
                        
-                       String tempText = responseElement.getText();
-                       if (tempText==null || "".equals(tempText)){
-                               OMElement child = 
responseElement.getFirstElement();
-                               if (child!=null)
-                                       tempText = child.getText();
+                       OMElement echoStringReturnElem = 
echoStringResponseElem.getFirstChildWithName(new QName 
(applicationNamespaceName,EchoStringReturn));
+                       if (echoStringReturnElem==null) { 
+                               System.out.println("Error: 'echoStringResponse' 
element does not have a 'EchoStringReturn' child");
+                               return;
                        }
                        
-                       
-                       tempText = (tempText==null)?"":tempText;
-                       
-                       System.out.println("Callback '" + name +  "' got 
result:" + tempText);
+                       String resultStr = echoStringReturnElem.getText();
+                       System.out.println("Callback '" + name +  "' got 
result:" + resultStr);
                        
                }
 

Modified: 
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/SyncPingClient.java
URL: 
http://svn.apache.org/viewcvs/webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/SyncPingClient.java?rev=381126&r1=381125&r2=381126&view=diff
==============================================================================
--- 
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/SyncPingClient.java
 (original)
+++ 
webservices/sandesha/trunk/samples/src/sandesha2/samples/interop/SyncPingClient.java
 Sun Feb 26 09:36:22 2006
@@ -21,33 +21,26 @@
 import javax.xml.namespace.QName;
 
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.client.InOnlyMEPClient;
-import org.apache.axis2.client.MessageSender;
-import org.apache.axis2.client.OperationClient;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.context.MessageContextConstants;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.ParameterImpl;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.engine.MessageReceiver;
+import org.apache.sandesha2.client.Sandesha2ClientAPI;
 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 org.apache.ws.commons.soap.SOAP11Constants;
-import org.apache.ws.commons.soap.SOAP12Constants;
-import org.apache.sandesha2.Sandesha2Constants;
-import org.apache.sandesha2.client.Sandesha2ClientAPI;
 
 
 public class SyncPingClient {
 
+       private static final String applicationNamespaceName = 
"http://tempuri.org/";; 
+       private static final String Ping = "Ping";
+       private static final String Text = "Text";
+       
        private String toIP = "127.0.0.1";
        
        private String toPort = "8080";
@@ -91,11 +84,11 @@
                clientOptions.setTo(new EndpointReference (toEPR));
                
clientOptions.setProperty(Sandesha2ClientAPI.SEQUENCE_KEY,"sequence1");
            
-               
//clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);
   //uncomment this to send messages without chunking.
+//             
clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);
   //uncomment this to send messages without chunking.
                
-               
//clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); 
  //uncomment this to send messages in SOAP 1.2
+//             
clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);   
//uncomment this to send messages in SOAP 1.2
                
-               
//clientOptions.setProperty(Sandesha2ClientAPI.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.WSRX);
  //uncomment this to send the messages according to the WSRX spec.
+//             
clientOptions.setProperty(Sandesha2ClientAPI.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.WSRX);
  //uncomment this to send the messages according to the WSRX spec.
                
                ServiceClient serviceClient = new ServiceClient 
(configContext,null);           
                clientOptions.setProperty("prop1","test1234");
@@ -115,14 +108,14 @@
        
        private static OMElement getPingOMBlock(String text) {
                OMFactory fac = OMAbstractFactory.getOMFactory();
-               OMNamespace ns = 
fac.createOMNamespace("http://tempuri.apache.org";,
-                               "ns1");
-               OMElement pingElement = fac.createOMElement("ping", ns);
-               OMElement paramElement = fac.createOMElement("param1", ns);
-               pingElement.addChild(paramElement);
-               paramElement.setText(text);
+               OMNamespace namespace = 
fac.createOMNamespace(applicationNamespaceName,"ns1");
+               OMElement pingElem = fac.createOMElement(Ping, namespace);
+               OMElement textElem = fac.createOMElement(Text, namespace);
+               
+               textElem.setText(text);
+               pingElem.addChild(textElem);
 
-               return pingElement;
+               return pingElem;
        }
        
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to