You are viewing a plain text version of this content. The canonical link for it is here.
Posted to sandesha-dev@ws.apache.org by ch...@apache.org on 2007/04/24 06:57:45 UTC

svn commit: r531722 [2/4] - in /webservices/sandesha/trunk/java: ./ modules/client/ modules/core/ modules/interop/ modules/interop/src/ modules/interop/src/main/ modules/interop/src/main/java/ modules/interop/src/main/java/org/ modules/interop/src/main...

Added: webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_2_1.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_2_1.java?view=auto&rev=531722
==============================================================================
--- webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_2_1.java (added)
+++ webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_2_1.java Mon Apr 23 21:57:43 2007
@@ -0,0 +1,320 @@
+/*
+ * 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.
+ */
+
+package org.apache.sandesha2.interop.rm1_1_clients;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPBody;
+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.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContextConstants;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.interop.RMInteropServiceCallbackHandler;
+import org.apache.sandesha2.interop.RMInteropServiceCallbackHandlerImpl;
+import org.apache.sandesha2.interop.RMInteropServiceStub;
+import org.apache.sandesha2.storage.beanmanagers.SenderBeanMgr;
+import org.apache.sandesha2.storage.inmemory.InMemorySenderBeanMgr;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.tempuri.EchoString;
+import org.tempuri.EchoStringRequestBodyType;
+
+public class Scenario_2_1 {
+	
+	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 static String toIP = "127.0.0.1";
+	private static String toPort = "8080";
+	private static String transportToIP = "127.0.0.1";
+	private static String transportToPort = "8070";
+	private static String servicePart = "/axis2/services/RMInteropService";
+	private static String toAddress = "http://" + toIP +  ":" + toPort + servicePart;
+	private static String transportToEPR = "http://" + transportToIP +  ":" + transportToPort + servicePart;
+	
+	private static String SANDESHA2_HOME = "<SANDESHA2_HOME>"; //Change this to ur path.
+	
+	private static String AXIS2_CLIENT_PATH = SANDESHA2_HOME + File.separator + "target" + File.separator +"repos" + File.separator + "client" + File.separator;   //this will be available after a maven build
+	
+	public static void main(String[] args) throws Exception,IOException {
+		
+		
+		String axisClientRepo = null;
+		if (args!=null && args.length>0)
+			axisClientRepo = args[0];
+		
+		if (axisClientRepo!=null && !"".equals(axisClientRepo)) {
+			AXIS2_CLIENT_PATH = axisClientRepo;
+			SANDESHA2_HOME = "";
+		}
+		
+		InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("sandesha2_interop.properties");
+
+		Properties properties = new Properties();
+		if (in != null) {
+			properties.load(in);
+			
+			toAddress = properties.getProperty("to");
+			transportToEPR = properties.getProperty("transportTo");
+		}
+		
+//		new Scenario_2_1 ().run();
+		new Scenario_2_1 ().runStubBased ();
+	}
+	
+	private void run () throws Exception {
+		
+		ConfigurationContext configurationContext = getConfigurationContext();
+		ServiceClient serviceClient = new ServiceClient (configurationContext,null);	
+		
+		Options clientOptions = new Options ();
+
+		String sequenceKey = "sequence4";
+		
+		//acksTo will be picked from replyTo
+		String acksTo = null; //serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+		
+		setUpOptions(clientOptions, sequenceKey,acksTo);
+
+		OMFactory factory = OMAbstractFactory.getOMFactory();
+		OMNamespace namespace = factory.createOMNamespace("urn:wsrm:InteropOptions","rmi");
+		OMElement acceptOfferElem = factory.createOMElement("acceptOffer",namespace);
+		OMElement useOfferElem = factory.createOMElement("useOffer",namespace);
+		acceptOfferElem.setText("true");
+		useOfferElem.setText("true");
+//		toEPR.addReferenceParameter(acceptOfferElem);
+//		toEPR.addReferenceParameter(useOfferElem);
+//		clientOptions.setManageSession(true); // without this reference params wont go.
+		
+		EndpointReference toEPR = new EndpointReference (toAddress);
+		serviceClient.setTargetEPR(toEPR);
+		
+		serviceClient.setOptions(clientOptions);
+
+		Callback callback1 = new TestCallback ("Callback 1");
+		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",sequenceKey),callback3);
+		
+        while (!callback3.isComplete()) {
+            Thread.sleep(1000);
+        }
+        
+        terminateSequence(serviceClient);
+	}
+
+	private static OMElement getEchoOMBlock(String text, String sequenceKey) {
+		OMFactory fac = OMAbstractFactory.getOMFactory();
+		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 {
+
+		String name = null;
+		
+		public TestCallback (String name) {
+			this.name = name;
+		}
+		
+		public void onComplete(AsyncResult result) {
+			//System.out.println("On Complete Called for " + text);
+			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;
+			}
+			
+			OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn));
+			if (echoStringReturnElem==null) { 
+				System.out.println("Error: 'echoStringResponse' element does not have a 'EchoStringReturn' child");
+				return;
+			}
+			
+			String resultStr = echoStringReturnElem.getText();
+			System.out.println("Callback '" + name +  "' got result:" + resultStr);
+		}
+
+		public void onError (Exception e) {
+			System.out.println("Error reported for test call back");
+			e.printStackTrace();
+		}
+	}
+	
+	private ConfigurationContext getConfigurationContext () throws AxisFault {
+
+		if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+			System.out.println("ERROR: Please set the directory you unzipped Sandesha2 as the first option.");
+			return null;
+		}
+
+		String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
+     
+		ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+		return configContext;
+	}
+	
+	private void setUpOptions (Options clientOptions, String sequenceKey, String acksTo) {
+
+		EndpointReference toEPR = new EndpointReference (toAddress);
+		clientOptions.setTo(toEPR);
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+		clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
+		clientOptions.setAction("urn:wsrm:EchoString");
+		
+		clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
+
+//		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.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
+		
+		clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
+		clientOptions.setProperty(SandeshaClientConstants.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);
+		clientOptions.setUseSeparateListener(true);
+		
+		
+		
+//		OMFactory factory = OMAbstractFactory.getOMFactory();
+//		OMNamespace namespace = factory.createOMNamespace("urn:wsrm:InteropOptions","rmi");
+//		OMElement acceptOfferElem = factory.createOMElement("acceptOffer",namespace);
+//		OMElement useOfferElem = factory.createOMElement("useOffer",namespace);
+//		acceptOfferElem.setText("true");
+//		useOfferElem.setText("true");
+//		toEPR.addReferenceParameter(acceptOfferElem);
+//		toEPR.addReferenceParameter(useOfferElem);
+//		clientOptions.setManageSession(true); // without this reference params wont go.
+//		
+		
+				
+	}
+	
+	
+	private void runStubBased () throws Exception {
+		ConfigurationContext configurationContext = getConfigurationContext();
+		
+		RMInteropServiceStub stub = new RMInteropServiceStub (configurationContext, toAddress);
+		ServiceClient stubServiceClient = stub._getServiceClient();
+		
+		String sequenceKey = "sequence4";
+		
+		//acksTo will be pickedup from replyTo
+		String acksTo = null;  //stubServiceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+		
+		Options options = stubServiceClient.getOptions();
+		setUpOptions(options, sequenceKey, acksTo);
+		
+		EchoString echoString = new EchoString ();
+		echoString.setEchoString (new EchoStringRequestBodyType ());
+		echoString.getEchoString().setSequence(sequenceKey);
+		echoString.getEchoString().setText("echo1");
+		
+		RMInteropServiceCallbackHandlerImpl callback1 = new RMInteropServiceCallbackHandlerImpl ("callback1");
+		stub.startEchoString(echoString, callback1);
+		
+		echoString = new EchoString ();
+		echoString.setEchoString (new EchoStringRequestBodyType ());
+		echoString.getEchoString().setSequence(sequenceKey);
+		echoString.getEchoString().setText("echo2");
+		
+		RMInteropServiceCallbackHandlerImpl callback2 = new RMInteropServiceCallbackHandlerImpl ("callback2");
+		stub.startEchoString(echoString, callback2);
+		
+		echoString = new EchoString ();
+		echoString.setEchoString (new EchoStringRequestBodyType ());
+		echoString.getEchoString().setSequence(sequenceKey);
+		echoString.getEchoString().setText("echo3");
+		
+		RMInteropServiceCallbackHandlerImpl callback3 = new RMInteropServiceCallbackHandlerImpl ("callback3");
+		stub.startEchoString(echoString, callback3);
+		
+		while (!callback3.isCompleted()) {
+			Thread.sleep(2000);
+		}
+		
+		terminateSequence (stubServiceClient);
+		
+	}
+	
+	private void terminateSequence (ServiceClient serviceClient) throws Exception {
+		
+    	SequenceReport sequenceReport = null;		
+		boolean complete = false;
+		while (!complete) {
+			sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+			if (sequenceReport!=null && sequenceReport.getCompletedMessages().size()==3) 
+				complete = true;
+			else {
+				try {
+					Thread.sleep(1000);
+				} catch (InterruptedException e1) {
+					e1.printStackTrace();
+	    		}
+			}
+		} 	
+       
+		Thread.sleep(6000);
+		
+        SandeshaClient.terminateSequence(serviceClient);
+//        serviceClient.cleanup();
+        		
+	}
+
+	
+}

Added: webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_2_2.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_2_2.java?view=auto&rev=531722
==============================================================================
--- webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_2_2.java (added)
+++ webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_2_2.java Mon Apr 23 21:57:43 2007
@@ -0,0 +1,320 @@
+/*
+ * 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.
+ */
+
+package org.apache.sandesha2.interop.rm1_1_clients;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPBody;
+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.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContextConstants;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.interop.RMInteropServiceCallbackHandlerImpl;
+import org.apache.sandesha2.interop.RMInteropServiceStub;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.tempuri.EchoString;
+import org.tempuri.EchoStringRequestBodyType;
+
+public class Scenario_2_2 {
+	
+	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 static String toIP = "127.0.0.1";
+	private static String toPort = "8080";
+	private static String transportToIP = "127.0.0.1";
+	private static String transportToPort = "8070";
+	private static String servicePart = "/axis2/services/RMInteropService";
+	private static String toAddress = "http://" + toIP +  ":" + toPort + servicePart;
+	private static String transportToAddress = "http://" + transportToIP +  ":" + transportToPort + servicePart;
+	
+	private static String SANDESHA2_HOME = "<SANDESHA2_HOME>"; //Change this to ur path.
+	
+	private static String AXIS2_CLIENT_PATH = SANDESHA2_HOME + File.separator + "target" + File.separator +"repos" + File.separator + "client" + File.separator;   //this will be available after a maven build
+	
+	public static void main(String[] args) throws Exception,IOException {
+		
+		
+		String axisClientRepo = null;
+		if (args!=null && args.length>0)
+			axisClientRepo = args[0];
+		
+		if (axisClientRepo!=null && !"".equals(axisClientRepo)) {
+			AXIS2_CLIENT_PATH = axisClientRepo;
+			SANDESHA2_HOME = "";
+		}
+		
+		InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("sandesha2_interop.properties");
+
+		Properties properties = new Properties();
+		if (in != null) {
+			properties.load(in);
+			toAddress = properties.getProperty("to");
+			transportToAddress = properties.getProperty("transportTo");
+		}
+		
+//		new Scenario_2_2 ().run();
+		new Scenario_2_2 ().runStubBased ();
+	}
+	
+	private void run () throws Exception {
+		
+		if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+			System.out.println("ERROR: Please set the directory you unzipped Sandesha2 as the first option.");
+			return;
+		}
+
+		String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
+     
+		ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+
+		ServiceClient serviceClient = new ServiceClient (configContext,null);	
+		
+		Options clientOptions = new Options ();
+		
+//		clientOptions.setProperty(Options.COPY_PROPERTIES,new Boolean (true));
+		clientOptions.setTo(new EndpointReference (toAddress));
+		
+		String acksTo = null; //serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+		clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
+		
+		String sequenceKey = "sequence4";
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+		
+		clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToAddress);
+		
+//		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.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
+		
+//		clientOptions.setProperty(SandeshaClient.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID());  //Uncomment this to offer a sequenceID for the incoming sequence.
+		
+//		clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
+
+		clientOptions.setAction("urn:wsrm:EchoString");
+		
+		//You must set the following two properties in the request-reply case.
+		clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+		clientOptions.setUseSeparateListener(true);
+		
+		serviceClient.setOptions(clientOptions);
+
+		Callback callback1 = new TestCallback ("Callback 1");
+		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",sequenceKey),callback3);
+		
+        while (!callback3.isComplete()) {
+            Thread.sleep(1000);
+        }
+        
+		Thread.sleep(3000);
+		
+        SandeshaClient.terminateSequence(serviceClient);
+        
+	}
+
+	private static OMElement getEchoOMBlock(String text, String sequenceKey) {
+		OMFactory fac = OMAbstractFactory.getOMFactory();
+		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 {
+
+		String name = null;
+		
+		public TestCallback (String name) {
+			this.name = name;
+		}
+		
+		public void onComplete(AsyncResult result) {
+			//System.out.println("On Complete Called for " + text);
+			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;
+			}
+			
+			OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn));
+			if (echoStringReturnElem==null) { 
+				System.out.println("Error: 'echoStringResponse' element does not have a 'EchoStringReturn' child");
+				return;
+			}
+			
+			String resultStr = echoStringReturnElem.getText();
+			System.out.println("Callback '" + name +  "' got result:" + resultStr);
+		}
+
+		public void onError (Exception e) {
+			// TODO Auto-generated method stub
+			System.out.println("Error reported for test call back");
+			e.printStackTrace();
+		}
+	}
+	
+	
+	private ConfigurationContext getConfigurationContext () throws AxisFault {
+
+		if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+			System.out.println("ERROR: Please set the directory you unzipped Sandesha2 as the first option.");
+			return null;
+		}
+
+		String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
+     
+		ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+		return configContext;
+	}
+	
+	private void setUpOptions (Options clientOptions, String sequenceKey, String acksTo) {
+
+		EndpointReference toEPR = new EndpointReference (toAddress);
+		clientOptions.setTo(toEPR);
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+		clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToAddress);
+		clientOptions.setAction("urn:wsrm:EchoString");
+		
+		clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
+
+//		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.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
+		
+		clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
+		
+		//You must set the following two properties in the request-reply case.
+		clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+		clientOptions.setUseSeparateListener(true);
+				
+	}
+	
+	
+	private void runStubBased () throws Exception {
+		ConfigurationContext configurationContext = getConfigurationContext();
+		
+		RMInteropServiceStub stub = new RMInteropServiceStub (configurationContext, toAddress);
+		ServiceClient stubServiceClient = stub._getServiceClient();
+		
+		String sequenceKey = "sequence4";
+		String acksTo = null; //serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+		
+		Options options = stubServiceClient.getOptions();
+		setUpOptions(options, sequenceKey, acksTo);
+		
+		EchoString echoString = new EchoString ();
+		echoString.setEchoString (new EchoStringRequestBodyType ());
+		echoString.getEchoString().setSequence(sequenceKey);
+		echoString.getEchoString().setText("echo1");
+		
+		RMInteropServiceCallbackHandlerImpl callback1 = new RMInteropServiceCallbackHandlerImpl ("callback1");
+		stub.startEchoString(echoString, callback1);
+		
+		echoString = new EchoString ();
+		echoString.setEchoString (new EchoStringRequestBodyType ());
+		echoString.getEchoString().setSequence(sequenceKey);
+		echoString.getEchoString().setText("echo2");
+		
+		RMInteropServiceCallbackHandlerImpl callback2 = new RMInteropServiceCallbackHandlerImpl ("callback2");
+		stub.startEchoString(echoString, callback2);
+		
+		echoString = new EchoString ();
+		echoString.setEchoString (new EchoStringRequestBodyType ());
+		echoString.getEchoString().setSequence(sequenceKey);
+		echoString.getEchoString().setText("echo3");
+		
+		RMInteropServiceCallbackHandlerImpl callback3 = new RMInteropServiceCallbackHandlerImpl ("callback3");
+		stub.startEchoString(echoString, callback3);
+		
+		while (!callback1.isCompleted() || !callback2.isCompleted() || !callback3.isCompleted()) {
+			Thread.sleep(2000);
+		}
+		
+		Thread.sleep(3000);
+		
+		terminateSequence (stubServiceClient);
+		
+	}
+	
+	private void terminateSequence (ServiceClient serviceClient) throws Exception {
+		
+    	SequenceReport sequenceReport = null;		
+		boolean complete = false;
+		while (!complete) {
+			sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+			if (sequenceReport!=null && sequenceReport.getCompletedMessages().size()==3) 
+				complete = true;
+			else {
+				try {
+					Thread.sleep(1000);
+				} catch (InterruptedException e1) {
+					e1.printStackTrace();
+	    		}
+			}
+		} 	
+       
+		Thread.sleep(6000);
+		
+        SandeshaClient.terminateSequence(serviceClient);
+//        serviceClient.cleanup();
+        		
+	}
+
+	
+}

Added: webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_2_3.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_2_3.java?view=auto&rev=531722
==============================================================================
--- webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_2_3.java (added)
+++ webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_2_3.java Mon Apr 23 21:57:43 2007
@@ -0,0 +1,333 @@
+/*
+ * 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.
+ */
+
+package org.apache.sandesha2.interop.rm1_1_clients;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPBody;
+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.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContextConstants;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.interop.RMInteropServiceCallbackHandlerImpl;
+import org.apache.sandesha2.interop.RMInteropServiceStub;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.tempuri.EchoString;
+import org.tempuri.EchoStringRequestBodyType;
+
+public class Scenario_2_3 {
+	
+	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 static String toIP = "127.0.0.1";
+	private static String toPort = "8080";
+	private static String transportToIP = "127.0.0.1";
+	private static String transportToPort = "8070";
+	private static String servicePart = "/axis2/services/RMInteropService";
+	private static String toAddress = "http://" + toIP +  ":" + toPort + servicePart;
+	private static String transportToEPR = "http://" + transportToIP +  ":" + transportToPort + servicePart;
+	
+	private static String SANDESHA2_HOME = "<SANDESHA2_HOME>"; //Change this to ur path.
+	
+	private static String AXIS2_CLIENT_PATH = SANDESHA2_HOME + File.separator + "target" + File.separator +"repos" + File.separator + "client" + File.separator;   //this will be available after a maven build
+	
+	public static void main(String[] args) throws Exception,IOException {
+		
+		
+		String axisClientRepo = null;
+		if (args!=null && args.length>0)
+			axisClientRepo = args[0];
+		
+		if (axisClientRepo!=null && !"".equals(axisClientRepo)) {
+			AXIS2_CLIENT_PATH = axisClientRepo;
+			SANDESHA2_HOME = "";
+		}
+		
+		InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("sandesha2_interop.properties");
+
+		Properties properties = new Properties();
+		if (in != null) {
+			properties.load(in);
+			toAddress = properties.getProperty("to");
+			transportToEPR = properties.getProperty("transportTo");
+		}
+		
+//		new Scenario_2_3 ().run();
+		new Scenario_2_3 ().runStubBased();
+	}
+	
+	private void run () throws Exception {
+		
+		if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+			System.out.println("ERROR: Please set the directory you unzipped Sandesha2 as the first option.");
+			return;
+		}
+
+		String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
+     
+		ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+
+		ServiceClient serviceClient = new ServiceClient (configContext,null);	
+		
+		Options clientOptions = new Options ();
+		
+		EndpointReference toEPR = new EndpointReference (toAddress);
+		populateToEPRToRejectOffers(toEPR);
+		
+//		clientOptions.setManageSession(true); // without this reference params wont go.
+		serviceClient.setTargetEPR(toEPR);
+		
+//		clientOptions.setProperty(Options.COPY_PROPERTIES,new Boolean (true));
+		clientOptions.setTo(toEPR);
+		
+		clientOptions.setAction("urn:wsrm:EchoString");
+		
+		String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+		clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
+		
+		String sequenceKey = "sequence4";
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+		
+		clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
+		
+//		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.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
+		clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
+		clientOptions.setProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID());  //single characted offers are declined by the server
+		
+		//You must set the following two properties in the request-reply case.
+		clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+		clientOptions.setUseSeparateListener(true);
+		
+		serviceClient.setOptions(clientOptions);
+
+		Callback callback1 = new TestCallback ("Callback 1");
+		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",sequenceKey),callback3);
+		
+        while (!callback3.isComplete()) {
+            Thread.sleep(1000);
+        }
+        
+       
+        SandeshaClient.terminateSequence(serviceClient);
+//        serviceClient.cleanup();
+	}
+
+	private static OMElement getEchoOMBlock(String text, String sequenceKey) {
+		OMFactory fac = OMAbstractFactory.getOMFactory();
+		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 {
+
+		String name = null;
+		
+		public TestCallback (String name) {
+			this.name = name;
+		}
+		
+		public void onComplete(AsyncResult result) {
+			//System.out.println("On Complete Called for " + text);
+			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;
+			}
+			
+			OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn));
+			if (echoStringReturnElem==null) { 
+				System.out.println("Error: 'echoStringResponse' element does not have a 'EchoStringReturn' child");
+				return;
+			}
+			
+			String resultStr = echoStringReturnElem.getText();
+			System.out.println("Callback '" + name +  "' got result:" + resultStr);
+		}
+
+		public void onError (Exception e) {
+			// TODO Auto-generated method stub
+			System.out.println("Error reported for test call back");
+			e.printStackTrace();
+		}
+	}
+	
+	private ConfigurationContext getConfigurationContext () throws AxisFault {
+
+		if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+			System.out.println("ERROR: Please set the directory you unzipped Sandesha2 as the first option.");
+			return null;
+		}
+
+		String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
+     
+		ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+		return configContext;
+	}
+	
+	private void setUpOptions (Options clientOptions, String sequenceKey, String acksTo) {
+
+		EndpointReference toEPR = new EndpointReference (toAddress);
+		clientOptions.setTo(toEPR);
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+		clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
+		clientOptions.setAction("urn:wsrm:EchoString");
+		clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
+
+//		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.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
+		
+		clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
+		clientOptions.setProperty(SandeshaClientConstants.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);
+		clientOptions.setUseSeparateListener(true);
+				
+	}
+	
+	
+	private void runStubBased () throws Exception {
+		ConfigurationContext configurationContext = getConfigurationContext();
+		
+		RMInteropServiceStub stub = new RMInteropServiceStub (configurationContext, toAddress);
+		ServiceClient stubServiceClient = stub._getServiceClient();
+		
+		String sequenceKey = "sequence4";
+		String acksTo = stubServiceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+		
+		Options options = stubServiceClient.getOptions();
+		setUpOptions(options, sequenceKey, acksTo);
+		populateToEPRToRejectOffers(stub._getServiceClient().getOptions().getTo());
+		
+		EchoString echoString = new EchoString ();
+		echoString.setEchoString (new EchoStringRequestBodyType ());
+		echoString.getEchoString().setSequence(sequenceKey);
+		echoString.getEchoString().setText("echo1");
+		
+		RMInteropServiceCallbackHandlerImpl callback1 = new RMInteropServiceCallbackHandlerImpl ("callback1");
+		stub.startEchoString(echoString, callback1);
+		
+		echoString = new EchoString ();
+		echoString.setEchoString (new EchoStringRequestBodyType ());
+		echoString.getEchoString().setSequence(sequenceKey);
+		echoString.getEchoString().setText("echo2");
+		
+		RMInteropServiceCallbackHandlerImpl callback2 = new RMInteropServiceCallbackHandlerImpl ("callback2");
+		stub.startEchoString(echoString, callback2);
+		
+		echoString = new EchoString ();
+		echoString.setEchoString (new EchoStringRequestBodyType ());
+		echoString.getEchoString().setSequence(sequenceKey);
+		echoString.getEchoString().setText("echo3");
+		
+		RMInteropServiceCallbackHandlerImpl callback3 = new RMInteropServiceCallbackHandlerImpl ("callback3");
+		stub.startEchoString(echoString, callback3);
+		
+		while (!callback3.isCompleted()) {
+			Thread.sleep(2000);
+		}
+		
+		terminateSequence (stubServiceClient);
+		
+	}
+	
+	private void terminateSequence (ServiceClient serviceClient) throws Exception {
+		
+    	SequenceReport sequenceReport = null;		
+		boolean complete = false;
+		while (!complete) {
+			sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+			if (sequenceReport!=null && sequenceReport.getCompletedMessages().size()==3) 
+				complete = true;
+			else {
+				try {
+					Thread.sleep(1000);
+				} catch (InterruptedException e1) {
+					e1.printStackTrace();
+	    		}
+			}
+		} 	
+       
+		Thread.sleep(6000);
+		
+        SandeshaClient.terminateSequence(serviceClient);
+//        serviceClient.cleanup();
+        		
+	}
+	
+	
+	private void populateToEPRToRejectOffers (EndpointReference toEPR) {
+		
+		OMFactory factory = OMAbstractFactory.getOMFactory();
+		OMNamespace namespace = factory.createOMNamespace("urn:wsrm:InteropOptions","rmi");
+		OMElement acceptOfferElem = factory.createOMElement("acceptOffer",namespace);
+		OMElement useOfferElem = factory.createOMElement("useOffer",namespace);
+		acceptOfferElem.setText("false");
+		useOfferElem.setText("false");
+		
+		toEPR.addReferenceParameter(acceptOfferElem);
+		toEPR.addReferenceParameter(useOfferElem);
+		
+	}
+
+	
+}

Added: webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_3_1.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_3_1.java?view=auto&rev=531722
==============================================================================
--- webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_3_1.java (added)
+++ webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_3_1.java Mon Apr 23 21:57:43 2007
@@ -0,0 +1,292 @@
+/*
+ * 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.
+ */
+
+package org.apache.sandesha2.interop.rm1_1_clients;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants;
+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.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContextConstants;
+import org.apache.axis2.description.OutInAxisOperation;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.interop.RMInteropServiceCallbackHandler;
+import org.apache.sandesha2.interop.RMInteropServiceCallbackHandlerImpl;
+import org.apache.sandesha2.interop.RMInteropServiceStub;
+import org.apache.sandesha2.storage.beanmanagers.SenderBeanMgr;
+import org.apache.sandesha2.storage.inmemory.InMemorySenderBeanMgr;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.tempuri.EchoString;
+import org.tempuri.EchoStringRequestBodyType;
+
+public class Scenario_3_1 {
+	
+	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 static String toIP = "127.0.0.1";
+	private static String toPort = "8080";
+	private static String transportToIP = "127.0.0.1";
+	private static String transportToPort = "8070";
+	private static String servicePart = "/axis2/services/RMInteropService";
+	private static String toAddress = "http://" + toIP +  ":" + toPort + servicePart;
+	private static String transportToEPR = "http://" + transportToIP +  ":" + transportToPort + servicePart;
+	
+	private static String SANDESHA2_HOME = "<SANDESHA2_HOME>"; //Change this to ur path.
+	
+	private static String AXIS2_CLIENT_PATH = SANDESHA2_HOME + File.separator + "target" + File.separator +"repos" + File.separator + "client" + File.separator;   //this will be available after a maven build
+	
+	public static void main(String[] args) throws Exception,IOException {
+		
+		
+		String axisClientRepo = null;
+		if (args!=null && args.length>0)
+			axisClientRepo = args[0];
+		
+		if (axisClientRepo!=null && !"".equals(axisClientRepo)) {
+			AXIS2_CLIENT_PATH = axisClientRepo;
+			SANDESHA2_HOME = "";
+		}
+		
+		InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("sandesha2_interop.properties");
+
+		Properties properties = new Properties();
+		if (in != null) {
+			properties.load(in);
+			
+			toAddress = properties.getProperty("to");
+			transportToEPR = properties.getProperty("transportTo");
+		}
+		
+//		new Scenario_2_1 ().run();
+		
+		
+		new Scenario_3_1 ().runStubBased ();
+	}
+	
+	private void run () throws Exception {
+		
+		ConfigurationContext configurationContext = getConfigurationContext();
+		ServiceClient serviceClient = new ServiceClient (configurationContext,null);	
+		
+		Options clientOptions = new Options ();
+
+		String sequenceKey = "sequence4";
+		String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+		
+		setUpOptions(clientOptions, sequenceKey,acksTo);
+
+		OMFactory factory = OMAbstractFactory.getOMFactory();
+		OMNamespace namespace = factory.createOMNamespace("urn:wsrm:InteropOptions","rmi");
+		OMElement acceptOfferElem = factory.createOMElement("acceptOffer",namespace);
+		OMElement useOfferElem = factory.createOMElement("useOffer",namespace);
+		acceptOfferElem.setText("true");
+		useOfferElem.setText("true");
+//		toEPR.addReferenceParameter(acceptOfferElem);
+//		toEPR.addReferenceParameter(useOfferElem);
+//		clientOptions.setManageSession(true); // without this reference params wont go.
+		
+		EndpointReference toEPR = new EndpointReference (toAddress);
+		serviceClient.setTargetEPR(toEPR);
+		
+		serviceClient.setOptions(clientOptions);
+
+		Callback callback1 = new TestCallback ("Callback 1");
+		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",sequenceKey),callback3);
+		
+        while (!callback3.isComplete()) {
+            Thread.sleep(1000);
+        }
+        
+		Thread.sleep(5000);
+		
+        SandeshaClient.terminateSequence(serviceClient);
+      			
+		Thread.sleep(10000);
+
+	}
+
+	private static OMElement getEchoOMBlock(String text, String sequenceKey) {
+		OMFactory fac = OMAbstractFactory.getOMFactory();
+		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 {
+
+		String name = null;
+		
+		public TestCallback (String name) {
+			this.name = name;
+		}
+		
+		public void onComplete(AsyncResult result) {
+			//System.out.println("On Complete Called for " + text);
+			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;
+			}
+			
+			OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn));
+			if (echoStringReturnElem==null) { 
+				System.out.println("Error: 'echoStringResponse' element does not have a 'EchoStringReturn' child");
+				return;
+			}
+			
+			String resultStr = echoStringReturnElem.getText();
+			System.out.println("Callback '" + name +  "' got result:" + resultStr);
+		}
+
+		public void onError (Exception e) {
+			// TODO Auto-generated method stub
+			System.out.println("Error reported for test call back");
+			e.printStackTrace();
+		}
+	}
+	
+	private ConfigurationContext getConfigurationContext () throws AxisFault {
+
+		if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+			System.out.println("ERROR: Please set the directory you unzipped Sandesha2 as the first option.");
+			throw new AxisFault ("Client not set up correctly");
+		}
+
+		String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
+     
+		ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+		return configContext;
+	}
+	
+	private void setUpOptions (Options clientOptions, String sequenceKey, String acksTo) {
+
+		EndpointReference toEPR = new EndpointReference (toAddress);
+		clientOptions.setTo(toEPR);
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+		clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
+		clientOptions.setAction("urn:wsrm:EchoString");
+
+//		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.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
+		
+		clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
+		clientOptions.setProperty(SandeshaClientConstants.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);
+		clientOptions.setUseSeparateListener(true);
+		
+//		clientOptions.setProperty(Constants.Configuration.USE_CUSTOM_LISTENER, new Boolean (true));
+				
+	}
+	
+	
+	private void runStubBased () throws Exception {
+
+		ConfigurationContext configurationContext = getConfigurationContext();
+		
+		RMInteropServiceStub stub = new RMInteropServiceStub (configurationContext, toAddress);
+		ServiceClient stubServiceClient = stub._getServiceClient();
+		
+		String sequenceKey = "sequence4";
+		String acksTo = stubServiceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+		
+		Options options = stubServiceClient.getOptions();
+		setUpOptions(options, sequenceKey, acksTo);
+		
+		EchoString echoString = new EchoString ();
+		echoString.setEchoString (new EchoStringRequestBodyType ());
+		echoString.getEchoString().setSequence(sequenceKey);
+		echoString.getEchoString().setText("echo1");
+		
+		options.setReplyTo(new EndpointReference (AddressingConstants.Final.WSA_ANONYMOUS_URL));
+		
+		RMInteropServiceCallbackHandlerImpl callback1 = new RMInteropServiceCallbackHandlerImpl ("callback1");
+		stub.startEchoString(echoString, callback1);
+		
+		echoString = new EchoString ();
+		echoString.setEchoString (new EchoStringRequestBodyType ());
+		echoString.getEchoString().setSequence(sequenceKey);
+		echoString.getEchoString().setText("echo2");
+		
+		RMInteropServiceCallbackHandlerImpl callback2 = new RMInteropServiceCallbackHandlerImpl ("callback2");
+		stub.startEchoString(echoString, callback2);
+		
+		echoString = new EchoString ();
+		echoString.setEchoString (new EchoStringRequestBodyType ());
+		echoString.getEchoString().setSequence(sequenceKey);
+		echoString.getEchoString().setText("echo3");
+		
+		RMInteropServiceCallbackHandlerImpl callback3 = new RMInteropServiceCallbackHandlerImpl ("callback3");
+		stub.startEchoString(echoString, callback3);
+		
+		while (!callback3.isCompleted()) {
+			Thread.sleep(2000);
+		}
+
+		Thread.sleep(5000);
+		
+        SandeshaClient.terminateSequence(stubServiceClient);
+      			
+		Thread.sleep(20000);
+		
+	}
+}

Added: webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_4_1.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_4_1.java?view=auto&rev=531722
==============================================================================
--- webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_4_1.java (added)
+++ webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_4_1.java Mon Apr 23 21:57:43 2007
@@ -0,0 +1,253 @@
+/*
+ * 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.
+ */
+
+package org.apache.sandesha2.interop.rm1_1_clients;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+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.AxisOperation;
+import org.apache.axis2.description.OutInAxisOperation;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyEngine;
+import org.apache.rahas.RahasConstants;
+import org.apache.rampart.RampartMessageData;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.interop.RMInteropServiceStub;
+import org.tempuri.Ping;
+
+import javax.xml.namespace.QName;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Properties;
+
+
+public class Scenario_4_1 {
+
+
+    private static final String applicationNamespaceName = "http://tempuri.org/"; 
+    private static final String PingRequest = "PingRequest";
+    private static final String Text = "Text";
+    
+    private static String toIP = "127.0.0.1";
+    private static String toPort = "9762";
+    private static String transportToIP = "127.0.0.1";
+    private static String transportToPort = "8070";
+    private static String servicePart = "/axis2/services/SecRMInteropService";
+    private static String toEPR = "http://" + toIP +  ":" + toPort + servicePart;
+    private static String transportToEPR = "http://" + transportToIP +  ":" + transportToPort + servicePart;
+    private final static String CLIENT_POLICY_PATH = "interop/conf/sec-client-policy.xml"; 
+    
+    private static String SANDESHA2_HOME = "<SANDESHA2_HOME>"; //Change this to ur path.
+    
+    private static String AXIS2_CLIENT_PATH = SANDESHA2_HOME + File.separator + "target" + File.separator +"repos" + File.separator + "client" + File.separator;   //this will be available after a maven build
+    
+    public static void main(String[] args) throws Exception  {
+        
+        String axisClientRepo = null;
+        if (args!=null && args.length>0)
+            axisClientRepo = args[0];
+        
+        if (axisClientRepo!=null && !"".equals(axisClientRepo)) {
+            AXIS2_CLIENT_PATH = axisClientRepo;
+            SANDESHA2_HOME = "";
+        }
+        
+        InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("sandesha2_interop.properties");
+
+        Properties properties = new Properties();
+        if (in != null) {
+            properties.load(in);
+            
+            toEPR = properties.getProperty("to");
+            transportToEPR = properties.getProperty("transportTo");
+        }
+
+
+      new Scenario_4_1 ().run();
+//        new Scenario_4_1().runStub();
+    }
+    
+    private void run () throws Exception {
+        
+        ConfigurationContext configurationContext = generateConfigContext();
+        
+        Options clientOptions = new Options ();
+        setUpOptions(clientOptions);
+        
+        ServiceClient serviceClient = new ServiceClient (configurationContext,null);
+        
+//      engage Rampart
+        serviceClient.engageModule(new QName("rampart"));
+        
+        serviceClient.setOptions(clientOptions);
+        
+        serviceClient.fireAndForget(getPingOMBlock("ping1"));
+        serviceClient.fireAndForget(getPingOMBlock("ping2"));
+        serviceClient.fireAndForget(getPingOMBlock("ping3"));
+        
+		SequenceReport sequenceReport = null;		
+		boolean complete = false;
+		while (!complete) {
+			sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+			if (sequenceReport!=null && sequenceReport.getCompletedMessages().size()==3) 
+				complete = true;
+			else {
+				try {
+					Thread.sleep(1000);
+				} catch (InterruptedException e1) {
+					e1.printStackTrace();
+	    		}
+			}
+		} 	
+		
+        Thread.sleep(3000);
+        
+        terminateSequence(serviceClient);
+        
+        Thread.sleep(3000);
+        
+        serviceClient.getOptions().setProperty(SandeshaClientConstants.UNRELIABLE_MESSAGE, Constants.VALUE_TRUE);
+        serviceClient.getOptions().setProperty(RampartMessageData.CANCEL_REQUEST, Constants.VALUE_TRUE);
+        serviceClient.fireAndForget(getPingOMBlock("cancel"));
+        
+        Thread.sleep(10000);
+        
+        serviceClient.cleanup();
+    }
+    
+    private static OMElement getPingOMBlock(String text) {
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        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 pingElem;
+    }
+    
+    private void runStub () throws Exception {
+        String targetEndpoint = toEPR;
+        ConfigurationContext configurationContext = generateConfigContext();
+        
+        RMInteropServiceStub stub = new RMInteropServiceStub (configurationContext, targetEndpoint);
+        ServiceClient serviceClient = stub._getServiceClient();
+        setUpOptions(serviceClient.getOptions());
+        
+        //engage Rampart
+        serviceClient.engageModule(new QName("rampart"));
+        
+		Ping ping = new Ping ();
+		ping.setText("ping1");
+		stub.Ping (ping);
+		
+		ping = new Ping ();
+		ping.setText("ping2");
+		stub.Ping (ping);
+		
+		ping = new Ping ();
+		ping.setText("ping3");
+		stub.Ping (ping);
+        
+        terminateSequence(serviceClient);
+        Thread.sleep(5000);
+        
+        serviceClient.getOptions().setProperty(SandeshaClientConstants.UNRELIABLE_MESSAGE, Constants.VALUE_TRUE);
+        serviceClient.getOptions().setProperty(RampartMessageData.CANCEL_REQUEST, Constants.VALUE_TRUE);
+        stub.Ping(ping);
+        
+        Thread.sleep(10000);
+//        stub._getServiceClient().cleanup();
+        
+    }
+    
+    private ConfigurationContext generateConfigContext () throws Exception {
+        if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+            System.out.println("ERROR: Please change <SANDESHA2_HOME> to your Sandesha2 installation directory.");
+            throw new Exception ("Client not set up correctly");
+        }
+        
+        String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
+        ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+
+        return configContext;
+    }
+    
+    private void setUpOptions (Options clientOptions) throws Exception {
+        clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
+//      clientOptions.setProperty(Options.COPY_PROPERTIES, new Boolean (true));
+        clientOptions.setTo(new EndpointReference (toEPR));
+        
+        String sequenceKey = "sequence1";
+        clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+        
+//      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.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
+        clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
+        
+        clientOptions.setAction("urn:wsrm:Ping");
+        
+        //Set Rampart policy
+        clientOptions.setProperty(RampartMessageData.KEY_RAMPART_POLICY, loadPolicy(CLIENT_POLICY_PATH));
+        
+        
+    }
+    
+    private void terminateSequence (ServiceClient serviceClient) throws SandeshaException {
+        SequenceReport sequenceReport = null;       
+        boolean complete = false;
+        while (!complete) {
+            sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+            if (sequenceReport!=null && sequenceReport.getCompletedMessages().size()==3) 
+                complete = true;
+            else {
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException e1) {
+                    e1.printStackTrace();
+                }
+            }
+        }       
+        
+        SandeshaClient.terminateSequence(serviceClient);
+    }
+    
+    private static Policy loadPolicy(String xmlPath) throws Exception {
+        StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
+        return PolicyEngine.getPolicy(builder.getDocumentElement());
+    }
+
+}

Added: webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_4_2.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_4_2.java?view=auto&rev=531722
==============================================================================
--- webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_4_2.java (added)
+++ webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/rm1_1_clients/Scenario_4_2.java Mon Apr 23 21:57:43 2007
@@ -0,0 +1,286 @@
+package org.apache.sandesha2.interop.rm1_1_clients;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants;
+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.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContextConstants;
+import org.apache.axis2.description.OutInAxisOperation;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyEngine;
+import org.apache.rampart.RampartMessageData;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.interop.RMInteropServiceCallbackHandlerImpl;
+import org.apache.sandesha2.interop.RMInteropServiceStub;
+import org.apache.sandesha2.interop.rm1_1_clients.Scenario_2_1.TestCallback;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.tempuri.EchoString;
+import org.tempuri.EchoStringRequestBodyType;
+
+public class Scenario_4_2 {
+	
+	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 static String toIP = "127.0.0.1";
+	private static String toPort = "8080";
+	private static String transportToIP = "127.0.0.1";
+	private static String transportToPort = "8070";
+	private static String servicePart = "/axis2/services/RMInteropService";
+	private static String toAddress = "http://" + toIP +  ":" + toPort + servicePart;
+	private static String transportToEPR = "http://" + transportToIP +  ":" + transportToPort + servicePart;
+	
+	private static String SANDESHA2_HOME = "<SANDESHA2_HOME>"; //Change this to ur path.
+	
+	private static String AXIS2_CLIENT_PATH = SANDESHA2_HOME + File.separator + "target" + File.separator +"repos" + File.separator + "client" + File.separator;   //this will be available after a maven build
+	
+	private final static String CLIENT_POLICY_PATH = "interop/conf/sec-client-policy.xml"; 
+	   
+	public static void main(String[] args) throws Exception,IOException {
+		
+		
+		String axisClientRepo = null;
+		if (args!=null && args.length>0)
+			axisClientRepo = args[0];
+		
+		if (axisClientRepo!=null && !"".equals(axisClientRepo)) {
+			AXIS2_CLIENT_PATH = axisClientRepo;
+			SANDESHA2_HOME = "";
+		}
+		
+		InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("sandesha2_interop.properties");
+
+		Properties properties = new Properties();
+		if (in != null) {
+			properties.load(in);
+			
+			toAddress = properties.getProperty("to");
+			transportToEPR = properties.getProperty("transportTo");
+		}
+		
+		new Scenario_4_2 ().run();
+//		new Scenario_3_1 ().runStubBased ();
+	}
+	
+	private void run () throws Exception {
+		
+		ConfigurationContext configurationContext = getConfigurationContext();
+		ServiceClient serviceClient = new ServiceClient (configurationContext,null);	
+		
+		Options clientOptions = new Options ();
+
+        serviceClient.engageModule(new QName("rampart"));
+        
+		String sequenceKey = "sequence4";
+		String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+		
+		setUpOptions(clientOptions, sequenceKey,acksTo);
+
+		OMFactory factory = OMAbstractFactory.getOMFactory();
+		OMNamespace namespace = factory.createOMNamespace("urn:wsrm:InteropOptions","rmi");
+		OMElement acceptOfferElem = factory.createOMElement("acceptOffer",namespace);
+		OMElement useOfferElem = factory.createOMElement("useOffer",namespace);
+		acceptOfferElem.setText("true");
+		useOfferElem.setText("true");
+//		toEPR.addReferenceParameter(acceptOfferElem);
+//		toEPR.addReferenceParameter(useOfferElem);
+//		clientOptions.setManageSession(true); // without this reference params wont go.
+		
+		clientOptions.setReplyTo(new EndpointReference (AddressingConstants.Final.WSA_ANONYMOUS_URL));
+		
+		EndpointReference toEPR = new EndpointReference (toAddress);
+		serviceClient.setTargetEPR(toEPR);
+		
+		serviceClient.setOptions(clientOptions);
+
+		Callback callback1 = new TestCallback ("Callback 1");
+		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",sequenceKey),callback3);
+		
+        while (!callback3.isComplete()) {
+            Thread.sleep(1000);
+        }
+        
+		Thread.sleep(3000);
+		
+        SandeshaClient.terminateSequence(serviceClient);
+      			
+		Thread.sleep(10000);
+
+	}
+
+	private static OMElement getEchoOMBlock(String text, String sequenceKey) {
+		OMFactory fac = OMAbstractFactory.getOMFactory();
+		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 {
+
+		String name = null;
+		
+		public TestCallback (String name) {
+			this.name = name;
+		}
+		
+		public void onComplete(AsyncResult result) {
+			//System.out.println("On Complete Called for " + text);
+			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;
+			}
+			
+			OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn));
+			if (echoStringReturnElem==null) { 
+				System.out.println("Error: 'echoStringResponse' element does not have a 'EchoStringReturn' child");
+				return;
+			}
+			
+			String resultStr = echoStringReturnElem.getText();
+			System.out.println("Callback '" + name +  "' got result:" + resultStr);
+		}
+
+		public void onError (Exception e) {
+			// TODO Auto-generated method stub
+			System.out.println("Error reported for test call back");
+			e.printStackTrace();
+		}
+	}
+	
+	private ConfigurationContext getConfigurationContext () throws AxisFault {
+
+		if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+			System.out.println("ERROR: Please set the directory you unzipped Sandesha2 as the first option.");
+			return null;
+		}
+
+		String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
+     
+		ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+		return configContext;
+	}
+	
+	private void setUpOptions (Options clientOptions, String sequenceKey, String acksTo) throws Exception {
+
+		EndpointReference toEPR = new EndpointReference (toAddress);
+		clientOptions.setTo(toEPR);
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+		clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
+		clientOptions.setAction("urn:wsrm:EchoString");
+
+//		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.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
+		
+		clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
+		clientOptions.setProperty(SandeshaClientConstants.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);
+		clientOptions.setUseSeparateListener(true);
+		
+//		clientOptions.setProperty(Constants.Configuration.USE_CUSTOM_LISTENER,new Boolean (true));
+		
+        clientOptions.setProperty(RampartMessageData.KEY_RAMPART_POLICY, loadPolicy(CLIENT_POLICY_PATH));
+	}
+	
+	
+	private void runStubBased () throws Exception {
+
+		ConfigurationContext configurationContext = getConfigurationContext();
+		
+		RMInteropServiceStub stub = new RMInteropServiceStub (configurationContext, toAddress);
+		ServiceClient stubServiceClient = stub._getServiceClient();
+		
+		String sequenceKey = "sequence4";
+		String acksTo = stubServiceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+		
+		Options options = stubServiceClient.getOptions();
+		setUpOptions(options, sequenceKey, acksTo);
+		
+		EchoString echoString = new EchoString ();
+		echoString.setEchoString (new EchoStringRequestBodyType ());
+		echoString.getEchoString().setSequence(sequenceKey);
+		echoString.getEchoString().setText("echo1");
+		
+		options.setReplyTo(new EndpointReference (AddressingConstants.Final.WSA_ANONYMOUS_URL));
+		
+		RMInteropServiceCallbackHandlerImpl callback1 = new RMInteropServiceCallbackHandlerImpl ("callback1");
+		stub.startEchoString(echoString, callback1);
+		
+		echoString = new EchoString ();
+		echoString.setEchoString (new EchoStringRequestBodyType ());
+		echoString.getEchoString().setSequence(sequenceKey);
+		echoString.getEchoString().setText("echo2");
+		
+		RMInteropServiceCallbackHandlerImpl callback2 = new RMInteropServiceCallbackHandlerImpl ("callback2");
+		stub.startEchoString(echoString, callback2);
+		
+		echoString = new EchoString ();
+		echoString.setEchoString (new EchoStringRequestBodyType ());
+		echoString.getEchoString().setSequence(sequenceKey);
+		echoString.getEchoString().setText("echo3");
+		
+		RMInteropServiceCallbackHandlerImpl callback3 = new RMInteropServiceCallbackHandlerImpl ("callback3");
+		stub.startEchoString(echoString, callback3);
+		
+		while (!callback3.isCompleted()) {
+			Thread.sleep(2000);
+		}
+
+		Thread.sleep(5000);
+		
+        SandeshaClient.terminateSequence(stubServiceClient);
+      			
+		Thread.sleep(10000);
+		
+	}
+    
+    private static Policy loadPolicy(String xmlPath) throws Exception {
+        StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
+        return PolicyEngine.getPolicy(builder.getDocumentElement());
+    }
+}

Added: webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/securerm/SecRMServiceImpl.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/securerm/SecRMServiceImpl.java?view=auto&rev=531722
==============================================================================
--- webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/securerm/SecRMServiceImpl.java (added)
+++ webservices/sandesha/trunk/java/modules/interop/src/main/java/org/apache/sandesha2/interop/securerm/SecRMServiceImpl.java Mon Apr 23 21:57:43 2007
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+package org.apache.sandesha2.interop.securerm;
+
+import java.util.HashMap;
+import javax.xml.namespace.QName;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+
+public class SecRMServiceImpl {
+
+	HashMap sequenceTextMap = new HashMap();
+	String namespaceValue = "http://tempuri.org/"; 
+	String Ping = "Ping";
+	String Text = "Text";
+	String echoString = "echoString";
+	String Sequence = "Sequence";
+	String echoStringResponse = "echoStringResponse";
+	String EchoStringReturn = "EchoStringReturn";
+	
+	public OMElement EchoString(OMElement echoStringElement) throws Exception {
+		if (echoStringElement==null)
+			throw new Exception ("Payload is null");
+		
+		OMElement textElement = echoStringElement.getFirstChildWithName(new QName (namespaceValue,Text));
+		OMElement sequenceElement = echoStringElement.getFirstChildWithName(new QName (namespaceValue,Sequence));
+		
+		if (textElement==null)
+			throw new Exception ("'Text' element is null");
+		
+		if (sequenceElement==null)
+			throw new Exception ("'Sequence' element is null");
+		
+		String text = textElement.getText();
+		String sequence = sequenceElement.getText();
+		
+		System.out.println("'EchoString' got text '" + text + "' for the sequence '" + sequence + "'.");
+		
+		String oldReturnValue = (String) sequenceTextMap.get(sequence);
+		String newReturnValue = oldReturnValue==null?text:oldReturnValue+text;
+		
+		sequenceTextMap.put(sequence, newReturnValue);
+		
+		OMFactory factory = echoStringElement.getOMFactory();
+		OMNamespace namespace = factory.createOMNamespace(namespaceValue, "ns1");
+		OMElement echoStringResponseElement = factory.createOMElement(echoStringResponse,namespace);
+		OMElement echoStringReturnElement = factory.createOMElement(EchoStringReturn, namespace);
+		echoStringReturnElement.setText(newReturnValue);
+		echoStringResponseElement.addChild(echoStringReturnElement);
+		
+		return echoStringResponseElement;
+	}
+
+	public void Ping(OMElement pingElement) throws Exception {
+		if (pingElement==null)
+			throw new Exception ("Payload is null");
+		
+		OMElement textElement = pingElement.getFirstChildWithName(new QName (namespaceValue,Text));
+		String text = textElement.getText();
+		
+		System.out.println("'Ping' got text '" + text + "'.");
+	}
+
+}

Added: webservices/sandesha/trunk/java/modules/interop/src/main/java/org/tempuri/EchoString.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/interop/src/main/java/org/tempuri/EchoString.java?view=auto&rev=531722
==============================================================================
--- webservices/sandesha/trunk/java/modules/interop/src/main/java/org/tempuri/EchoString.java (added)
+++ webservices/sandesha/trunk/java/modules/interop/src/main/java/org/tempuri/EchoString.java Mon Apr 23 21:57:43 2007
@@ -0,0 +1,283 @@
+/*
+ * 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.
+ */
+
+package org.tempuri;
+
+/**
+ * EchoString bean class
+ */
+
+public class EchoString implements org.apache.axis2.databinding.ADBBean {
+
+	public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName(
+			"http://tempuri.org/", "echoString", "ns1");
+
+	/**
+	 * field for EchoString
+	 */
+
+	protected org.tempuri.EchoStringRequestBodyType localEchoString;
+
+	/**
+	 * Auto generated getter method
+	 * 
+	 * @return org.tempuri.EchoStringRequestBodyType
+	 */
+	public org.tempuri.EchoStringRequestBodyType getEchoString() {
+		return localEchoString;
+	}
+
+	/**
+	 * Auto generated setter method
+	 * 
+	 * @param param
+	 *            EchoString
+	 */
+	public void setEchoString(org.tempuri.EchoStringRequestBodyType param) {
+
+		this.localEchoString = param;
+
+	}
+
+	/**
+	 * 
+	 * @param parentQName
+	 * @param factory
+	 * @return org.apache.axiom.om.OMElement
+	 */
+	public org.apache.axiom.om.OMElement getOMElement(
+			final javax.xml.namespace.QName parentQName,
+			final org.apache.axiom.om.OMFactory factory) {
+
+		org.apache.axiom.om.OMDataSource dataSource = new org.apache.axis2.databinding.ADBDataSource(
+				this, parentQName) {
+
+			public void serialize(javax.xml.stream.XMLStreamWriter xmlWriter)
+					throws javax.xml.stream.XMLStreamException {
+
+				// We can safely assume an element has only one type associated
+				// with it
+
+				if (localEchoString == null) {
+					java.lang.String namespace = "http://tempuri.org/";
+
+					if (!namespace.equals("")) {
+						java.lang.String prefix = xmlWriter
+								.getPrefix(namespace);
+
+						if (prefix == null) {
+							prefix = org.apache.axis2.databinding.utils.BeanUtil
+									.getUniquePrefix();
+
+							xmlWriter.writeStartElement(prefix, "echoString",
+									namespace);
+							xmlWriter.writeNamespace(prefix, namespace);
+							xmlWriter.setPrefix(prefix, namespace);
+
+						} else {
+							xmlWriter
+									.writeStartElement(namespace, "echoString");
+						}
+
+					} else {
+						xmlWriter.writeStartElement("echoString");
+					}
+
+					// write the nil attribute
+					writeAttribute("xsi",
+							"http://www.w3.org/2001/XMLSchema-instance", "nil",
+							"true", xmlWriter);
+					xmlWriter.writeEndElement();
+				} else {
+					localEchoString.getOMElement(MY_QNAME, factory).serialize(
+							xmlWriter);
+				}
+
+			}
+
+			/**
+			 * Util method to write an attribute with the ns prefix
+			 */
+			private void writeAttribute(java.lang.String prefix,
+					java.lang.String namespace, java.lang.String attName,
+					java.lang.String attValue,
+					javax.xml.stream.XMLStreamWriter xmlWriter)
+					throws javax.xml.stream.XMLStreamException {
+				if (xmlWriter.getPrefix(namespace) == null) {
+					xmlWriter.writeNamespace(prefix, namespace);
+					xmlWriter.setPrefix(prefix, namespace);
+
+				}
+
+				xmlWriter.writeAttribute(namespace, attName, attValue);
+
+			}
+
+			/**
+			 * Util method to write an attribute without the ns prefix
+			 */
+			private void writeAttribute(java.lang.String namespace,
+					java.lang.String attName, java.lang.String attValue,
+					javax.xml.stream.XMLStreamWriter xmlWriter)
+					throws javax.xml.stream.XMLStreamException {
+				if (namespace.equals("")) {
+					xmlWriter.writeAttribute(attName, attValue);
+				} else {
+					registerPrefix(xmlWriter, namespace);
+					xmlWriter.writeAttribute(namespace, attName, attValue);
+				}
+			}
+
+			/**
+			 * Register a namespace prefix
+			 */
+			private java.lang.String registerPrefix(
+					javax.xml.stream.XMLStreamWriter xmlWriter,
+					java.lang.String namespace)
+					throws javax.xml.stream.XMLStreamException {
+				java.lang.String prefix = xmlWriter.getPrefix(namespace);
+
+				if (prefix == null) {
+					prefix = createPrefix();
+
+					while (xmlWriter.getNamespaceContext().getNamespaceURI(
+							prefix) != null) {
+						prefix = createPrefix();
+					}
+
+					xmlWriter.writeNamespace(prefix, namespace);
+					xmlWriter.setPrefix(prefix, namespace);
+				}
+
+				return prefix;
+			}
+
+			/**
+			 * Create a prefix
+			 */
+			private java.lang.String createPrefix() {
+				return "ns" + (int) Math.random();
+			}
+		};
+
+		// ignore the QName passed in - we send only OUR QName!
+		return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl(MY_QNAME,
+				factory, dataSource);
+
+	}
+
+	/**
+	 * databinding method to get an XML representation of this object
+	 * 
+	 */
+	public javax.xml.stream.XMLStreamReader getPullParser(
+			javax.xml.namespace.QName qName) {
+
+		// We can safely assume an element has only one type associated with it
+
+		if (localEchoString == null) {
+			return new org.apache.axis2.databinding.utils.reader.NullXMLStreamReader(
+					MY_QNAME);
+		} else {
+			return localEchoString.getPullParser(MY_QNAME);
+		}
+
+	}
+
+	/**
+	 * Factory class that keeps the parse method
+	 */
+	public static class Factory {
+
+		/**
+		 * static method to create the object Precondition: If this object is an
+		 * element, the current or next start element starts this object and any
+		 * intervening reader events are ignorable If this object is not an
+		 * element, it is a complex type and the reader is at the event just
+		 * after the outer start element Postcondition: If this object is an
+		 * element, the reader is positioned at its end element If this object
+		 * is a complex type, the reader is positioned at the end element of its
+		 * outer element
+		 */
+		public static EchoString parse(javax.xml.stream.XMLStreamReader reader)
+				throws java.lang.Exception {
+			EchoString object = new EchoString();
+			int event;
+			try {
+
+				while (!reader.isStartElement() && !reader.isEndElement())
+					reader.next();
+
+				if ("true".equals(reader.getAttributeValue(
+						"http://www.w3.org/2001/XMLSchema-instance", "nil"))) {
+					// Skip the element and report the null value. It cannot
+					// have subelements.
+					while (!reader.isEndElement())
+						reader.next();
+					return null;
+				}
+
+				// Note all attributes that were handled. Used to differ normal
+				// attributes
+				// from anyAttributes.
+				java.util.Vector handledAttributes = new java.util.Vector();
+
+				boolean isReaderMTOMAware = false;
+
+				try {
+					isReaderMTOMAware = java.lang.Boolean.TRUE
+							.equals(reader
+									.getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE));
+				} catch (java.lang.IllegalArgumentException e) {
+					isReaderMTOMAware = false;
+				}
+
+				while (!reader.isEndElement()) {
+					if (reader.isStartElement()) {
+
+						if (reader.isStartElement()
+								&& new javax.xml.namespace.QName(
+										"http://tempuri.org/", "echoString")
+										.equals(reader.getName())) {
+
+							object
+									.setEchoString(org.tempuri.EchoStringRequestBodyType.Factory
+											.parse(reader));
+
+						} // End of if for expected property start element
+
+						else {
+							// A start element we are not expecting indicates an
+							// invalid parameter was passed
+							throw new java.lang.RuntimeException(
+									"Unexpected subelement "
+											+ reader.getLocalName());
+						}
+
+					} else
+						reader.next();
+				} // end of while loop
+
+			} catch (javax.xml.stream.XMLStreamException e) {
+				throw new java.lang.Exception(e);
+			}
+
+			return object;
+		}
+
+	}// end of factory class
+
+}



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