You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by ch...@apache.org on 2005/10/24 06:47:31 UTC

svn commit: r327965 - in /webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2: ./ clients/ samples/

Author: chamikara
Date: Sun Oct 23 21:47:10 2005
New Revision: 327965

URL: http://svn.apache.org/viewcvs?rev=327965&view=rev
Log:
Added the 4 sample classes
SyncPing
SyncEcho
AsyncPing
AsyncEcho

Yep. Sandesha2 is working for all 4 scenarios now.

Added:
    webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/
    webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/AsyncEchoClient.java
    webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/AsyncPingClient.java
    webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/SyncEchoClient.java
    webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/SyncPingClient.java
Removed:
    webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/samples/SampleClient.java
Modified:
    webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/SimpleSandesha2Server.java

Modified: webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/SimpleSandesha2Server.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/SimpleSandesha2Server.java?rev=327965&r1=327964&r2=327965&view=diff
==============================================================================
--- webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/SimpleSandesha2Server.java (original)
+++ webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/SimpleSandesha2Server.java Sun Oct 23 21:47:10 2005
@@ -21,7 +21,7 @@
 
 public class SimpleSandesha2Server {
 
-	private static String SANDESHA_HOME = "E:\\sandesha\\sandesha 2\\"; //Change this to ur path.
+	private static String SANDESHA_HOME = "E:\\sandesha\\sandesha 2\\code\\checkouts\\Aug_25_2005\\"; //Change this to ur path.
 	
 	private static String AXIS2_SERVER_PATH = SANDESHA_HOME + "target\\server\\";   //this will be available after a maven build
 	

Added: webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/AsyncEchoClient.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/AsyncEchoClient.java?rev=327965&view=auto
==============================================================================
--- webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/AsyncEchoClient.java (added)
+++ webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/AsyncEchoClient.java Sun Oct 23 21:47:10 2005
@@ -0,0 +1,134 @@
+/*
+ * 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.clients;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.clientapi.AsyncResult;
+import org.apache.axis2.clientapi.Call;
+import org.apache.axis2.clientapi.Callback;
+import org.apache.axis2.clientapi.MessageSender;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMFactory;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.sandesha2.Constants;
+import org.apache.sandesha2.util.SandeshaUtil;
+
+public class AsyncEchoClient {
+	private static String sandesha1TO = "http://localhost:8070/axis/services/RMSampleService";
+
+	private static String replyTo = "http://localhost:9070/axis/services/RMSampleService";
+	
+	private static String sandesha2TO = "http://localhost:8070/axis2/services/InteropService";
+
+	private static String SANDESHA_HOME = "E:\\sandesha\\sandesha 2\\code\\checkouts\\"; //Change this to ur path.
+	
+	private static String AXIS2_CLIENT_PATH = SANDESHA_HOME + "target\\client\\";   //this will be available after a maven build
+	
+	public static void main(String[] args) throws AxisFault {
+		new AsyncEchoClient ().run();
+	}
+	
+	private void run () throws AxisFault {
+		Call call = new Call(AXIS2_CLIENT_PATH);
+		call.engageModule(new QName("sandesha"));
+		call.set(Constants.AcksTo,"http://localhost:9070/axis2/services/AnonymousService/echoString"); //Optional
+		call.setTo(new EndpointReference(sandesha2TO));
+		call.set(Constants.SEQUENCE_KEY,"sequence1");  //Optional
+		call.set(Constants.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID());  //Optional
+		call.setTransportInfo(org.apache.axis2.Constants.TRANSPORT_HTTP,org.apache.axis2.Constants.TRANSPORT_HTTP,true);
+		Callback callback1 = new TestCallback ("Callback 1");
+		call.invokeNonBlocking("echoString", getEchoOMBlock("echo1"),callback1);
+		Callback callback2 = new TestCallback ("Callback 2");
+		call.invokeNonBlocking("echoString", getEchoOMBlock("echo2"),callback2);
+		call.set(Constants.LAST_MESSAGE, "true");
+		Callback callback3 = new TestCallback ("Callback 3");
+		call.invokeNonBlocking("echoString", getEchoOMBlock("echo3"),callback3);
+
+	}
+
+	public void testEcho () throws AxisFault {
+		
+		Call call = new Call(AXIS2_CLIENT_PATH);
+		call.engageModule(new QName("sandesha"));
+
+		call.set(Constants.AcksTo,"http://localhost:9070/axis2/services/AnonymousService/echoString"); //Optional
+		call.setTo(new EndpointReference(sandesha2TO));
+		call.set(Constants.SEQUENCE_KEY,"sequence1");  //Optional
+		call.set(Constants.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID());  //Optional
+		call.setTransportInfo(org.apache.axis2.Constants.TRANSPORT_HTTP,org.apache.axis2.Constants.TRANSPORT_HTTP,true);
+		Callback callback1 = new TestCallback ("Callback 1");
+		call.invokeNonBlocking("echoString", getEchoOMBlock("echo1"),callback1);
+		Callback callback2 = new TestCallback ("Callback 2");
+		call.invokeNonBlocking("echoString", getEchoOMBlock("echo2"),callback2);
+		call.set(Constants.LAST_MESSAGE, "true");
+		Callback callback3 = new TestCallback ("Callback 3");
+		call.invokeNonBlocking("echoString", getEchoOMBlock("echo3"),callback3);
+	}
+
+	private static OMElement getEchoOMBlock(String text) {
+		OMFactory fac = OMAbstractFactory.getOMFactory();
+		OMNamespace defaultNS = fac.createOMNamespace("",null);
+		OMElement echoElement = fac.createOMElement("echoString", defaultNS);
+		OMElement paramElement = fac.createOMElement("text", defaultNS);
+		echoElement.addChild(paramElement);
+		paramElement.setText(text);
+
+		return echoElement;
+	}
+
+	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);
+			OMElement responseElement = result.getResponseEnvelope().getBody().getFirstElement();
+			if (responseElement==null) {
+				System.out.println("Response element is null");
+				return;
+			}
+			
+			String tempText = responseElement.getText();
+			if (tempText==null || "".equals(tempText)){
+				OMElement child = responseElement.getFirstElement();
+				if (child!=null)
+					tempText = child.getText();
+			}
+			
+			
+			tempText = (tempText==null)?"":tempText;
+			
+			System.out.println("Callback '" + name +  "' got result:" + tempText);
+			
+		}
+
+		public void reportError(Exception e) {
+			// TODO Auto-generated method stub
+			System.out.println("Error reported for test call back");
+		}
+	}
+
+	
+}

Added: webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/AsyncPingClient.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/AsyncPingClient.java?rev=327965&view=auto
==============================================================================
--- webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/AsyncPingClient.java (added)
+++ webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/AsyncPingClient.java Sun Oct 23 21:47:10 2005
@@ -0,0 +1,71 @@
+/*
+ * 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.clients;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.clientapi.MessageSender;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMFactory;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.sandesha2.Constants;
+
+
+public class AsyncPingClient {
+
+	private static String sandesha1TO = "http://localhost:8070/axis/services/RMSampleService";
+
+	private static String replyTo = "http://localhost:9070/axis/services/RMSampleService";
+	
+	private static String sandesha2TO = "http://localhost:8070/axis2/services/InteropService";
+
+	private static String SANDESHA_HOME = "E:\\sandesha\\sandesha 2\\code\\checkouts\\"; //Change this to ur path.
+	
+	private static String AXIS2_CLIENT_PATH = SANDESHA_HOME + "target\\client\\";   //this will be available after a maven build
+	
+	public static void main(String[] args) throws AxisFault {
+		new AsyncPingClient().run();
+	}
+	
+	public void run () throws AxisFault {
+		MessageSender sender = new MessageSender (AXIS2_CLIENT_PATH);
+		sender.set(Constants.AcksTo,"http://localhost:9070/axis2/services/AnonymousService/ping");
+		sender.engageModule(new QName ("sandesha"));
+		sender.setTo(new EndpointReference(sandesha2TO));
+		sender.set(Constants.SEQUENCE_KEY,"sequence1");
+		sender.send("ping",getPingOMBlock("ping1"));
+		sender.send("ping",getPingOMBlock("ping2"));
+		sender.set(Constants.LAST_MESSAGE, "true");
+		sender.send("ping",getPingOMBlock("ping3"));
+	}
+	
+	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);
+
+		return pingElement;
+	}
+	
+}

Added: webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/SyncEchoClient.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/SyncEchoClient.java?rev=327965&view=auto
==============================================================================
--- webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/SyncEchoClient.java (added)
+++ webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/SyncEchoClient.java Sun Oct 23 21:47:10 2005
@@ -0,0 +1,132 @@
+/*
+ * 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.clients;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.clientapi.AsyncResult;
+import org.apache.axis2.clientapi.Call;
+import org.apache.axis2.clientapi.Callback;
+import org.apache.axis2.clientapi.MessageSender;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMFactory;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.sandesha2.Constants;
+import org.apache.sandesha2.util.SandeshaUtil;
+
+public class SyncEchoClient {
+
+	private static String sandesha1TO = "http://localhost:8070/axis/services/RMSampleService";
+
+	private static String replyTo = "http://localhost:9070/axis/services/RMSampleService";
+	
+	private static String sandesha2TO = "http://localhost:8070/axis2/services/InteropService";
+
+	private static String SANDESHA_HOME = "E:\\sandesha\\sandesha 2\\code\\checkouts\\"; //Change this to ur path.
+	
+	private static String AXIS2_CLIENT_PATH = SANDESHA_HOME + "target\\client\\";   //this will be available after a maven build
+	
+	public static void main(String[] args) throws AxisFault {
+		new SyncEchoClient().run();
+	}
+	
+	private void run () throws AxisFault {
+		Call call = new Call(AXIS2_CLIENT_PATH);
+		call.engageModule(new QName("sandesha"));
+		call.setTo(new EndpointReference(sandesha2TO));
+		call.set(Constants.SEQUENCE_KEY,"sequence1");  //Optional
+		call.set(Constants.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID());  //Optional
+		call.setTransportInfo(org.apache.axis2.Constants.TRANSPORT_HTTP,org.apache.axis2.Constants.TRANSPORT_HTTP,true);
+		Callback callback1 = new TestCallback ("Callback 1");
+		call.invokeNonBlocking("echoString", getEchoOMBlock("echo1"),callback1);
+		Callback callback2 = new TestCallback ("Callback 2");
+		call.invokeNonBlocking("echoString", getEchoOMBlock("echo2"),callback2);
+		call.set(Constants.LAST_MESSAGE, "true");
+		Callback callback3 = new TestCallback ("Callback 3");
+		call.invokeNonBlocking("echoString", getEchoOMBlock("echo3"),callback3);
+	}
+
+	public void testEcho () throws AxisFault {
+		
+		Call call = new Call(AXIS2_CLIENT_PATH);
+		call.engageModule(new QName("sandesha"));
+
+		call.set(Constants.AcksTo,"http://localhost:9070/axis2/services/AnonymousService/echoString"); //Optional
+		call.setTo(new EndpointReference(sandesha2TO));
+		call.set(Constants.SEQUENCE_KEY,"sequence1");  //Optional
+		call.set(Constants.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID());  //Optional
+		call.setTransportInfo(org.apache.axis2.Constants.TRANSPORT_HTTP,org.apache.axis2.Constants.TRANSPORT_HTTP,true);
+		Callback callback1 = new TestCallback ("Callback 1");
+		call.invokeNonBlocking("echoString", getEchoOMBlock("echo1"),callback1);
+		Callback callback2 = new TestCallback ("Callback 2");
+		call.invokeNonBlocking("echoString", getEchoOMBlock("echo2"),callback2);
+		call.set(Constants.LAST_MESSAGE, "true");
+		Callback callback3 = new TestCallback ("Callback 3");
+		call.invokeNonBlocking("echoString", getEchoOMBlock("echo3"),callback3);
+	}
+
+	private static OMElement getEchoOMBlock(String text) {
+		OMFactory fac = OMAbstractFactory.getOMFactory();
+		OMNamespace defaultNS = fac.createOMNamespace("",null);
+		OMElement echoElement = fac.createOMElement("echoString", defaultNS);
+		OMElement paramElement = fac.createOMElement("text", defaultNS);
+		echoElement.addChild(paramElement);
+		paramElement.setText(text);
+
+		return echoElement;
+	}
+
+	private 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);
+			OMElement responseElement = result.getResponseEnvelope().getBody().getFirstElement();
+			if (responseElement==null) {
+				System.out.println("Response element is null");
+				return;
+			}
+			
+			String tempText = responseElement.getText();
+			if (tempText==null || "".equals(tempText)){
+				OMElement child = responseElement.getFirstElement();
+				if (child!=null)
+					tempText = child.getText();
+			}
+			
+			
+			tempText = (tempText==null)?"":tempText;
+			
+			System.out.println("Callback '" + name +  "' got result:" + tempText);
+			
+		}
+
+		public void reportError(Exception e) {
+			// TODO Auto-generated method stub
+			System.out.println("Error reported for test call back");
+		}
+	}
+	
+}

Added: webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/SyncPingClient.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/SyncPingClient.java?rev=327965&view=auto
==============================================================================
--- webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/SyncPingClient.java (added)
+++ webservices/sandesha/trunk/samples/interop/src/org/apache/sandesha2/clients/SyncPingClient.java Sun Oct 23 21:47:10 2005
@@ -0,0 +1,69 @@
+/*
+ * 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.clients;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.clientapi.MessageSender;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMFactory;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.sandesha2.Constants;
+
+public class SyncPingClient {
+
+	private static String sandesha1TO = "http://localhost:8070/axis/services/RMSampleService";
+
+	private static String replyTo = "http://localhost:9070/axis/services/RMSampleService";
+	
+	private static String sandesha2TO = "http://localhost:8070/axis2/services/InteropService";
+
+	private static String SANDESHA_HOME = "E:\\sandesha\\sandesha 2\\code\\checkouts\\"; //Change this to ur path.
+	
+	private static String AXIS2_CLIENT_PATH = SANDESHA_HOME + "target\\client\\";   //this will be available after a maven build
+	
+	public static void main(String[] args) throws AxisFault {
+		new SyncPingClient ().run();
+	}
+	
+	public void run () throws AxisFault {
+		MessageSender sender = new MessageSender (AXIS2_CLIENT_PATH);
+		sender.engageModule(new QName ("sandesha"));
+		sender.setTo(new EndpointReference(sandesha2TO));
+		sender.set(Constants.SEQUENCE_KEY,"sequence1");
+		sender.send("ping",getPingOMBlock("ping1"));
+		sender.send("ping",getPingOMBlock("ping2"));
+		sender.set(Constants.LAST_MESSAGE, "true");
+		sender.send("ping",getPingOMBlock("ping3"));
+	}
+	
+	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);
+
+		return pingElement;
+	}
+	
+}



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