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 2006/04/23 13:09:28 UTC
svn commit: r396253 - in /webservices/sandesha/trunk/samples:
conf/userguide/ src/sandesha2/samples/userguide/
Author: chamikara
Date: Sun Apr 23 04:09:26 2006
New Revision: 396253
URL: http://svn.apache.org/viewcvs?rev=396253&view=rev
Log:
Updated sample files. Added the two clients from the User Guide
Added:
webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/UserguideEchoClient.java
webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/UserguidePingClient.java
Modified:
webservices/sandesha/trunk/samples/conf/userguide/services.xml
webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/AsyncEchoClient.java
webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/AsyncPingClient.java
webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/RMSampleService.java
webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/SyncEchoClient.java
webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/SyncPingClient.java
Modified: webservices/sandesha/trunk/samples/conf/userguide/services.xml
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/samples/conf/userguide/services.xml?rev=396253&r1=396252&r2=396253&view=diff
==============================================================================
--- webservices/sandesha/trunk/samples/conf/userguide/services.xml (original)
+++ webservices/sandesha/trunk/samples/conf/userguide/services.xml Sun Apr 23 04:09:26 2006
@@ -10,17 +10,9 @@
<operation name="ping" mep="http://www.w3.org/2004/08/wsdl/in-only">
<messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver" />
</operation>
-
- <operation name="Ping" mep="http://www.w3.org/2004/08/wsdl/in-only">
- <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver" />
- </operation>
<operation name="echoString">
<messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />
- </operation>
-
- <operation name="EchoString">
- <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />
</operation>
</service>
Modified: webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/AsyncEchoClient.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/AsyncEchoClient.java?rev=396253&r1=396252&r2=396253&view=diff
==============================================================================
--- webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/AsyncEchoClient.java (original)
+++ webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/AsyncEchoClient.java Sun Apr 23 04:09:26 2006
@@ -20,6 +20,12 @@
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.Constants;
import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.addressing.EndpointReference;
@@ -30,16 +36,8 @@
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.context.MessageContextConstants;
-import org.apache.axis2.description.ClientUtils;
-import org.apache.sandesha2.client.SandeshaClient;
import org.apache.sandesha2.client.SandeshaClientConstants;
import org.apache.sandesha2.util.SandeshaUtil;
-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;
public class AsyncEchoClient {
@@ -52,10 +50,6 @@
private String toIP = "127.0.0.1";
- private String ackIP = "127.0.0.1";
-
- private String ackPort = "9070";
-
private String toPort = "8070";
private String transportToPort = "8070";
@@ -63,8 +57,6 @@
private String toEPR = "http://" + toIP + ":" + toPort + "/axis2/services/RMSampleService";
private String transportToEPR = "http://" + toIP + ":" + transportToPort + "/axis2/services/RMSampleService";
-
- //private String acksToEPR = "http://" + ackIP + ":" + ackPort + "/axis2/services/" + "__ANONYMOUS_SERVICE__";
private static String SANDESHA2_HOME = "<SANDESHA2_HOME>"; //Change this to ur path.
Modified: webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/AsyncPingClient.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/AsyncPingClient.java?rev=396253&r1=396252&r2=396253&view=diff
==============================================================================
--- webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/AsyncPingClient.java (original)
+++ webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/AsyncPingClient.java Sun Apr 23 04:09:26 2006
@@ -18,8 +18,10 @@
import java.io.File;
-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.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
@@ -30,16 +32,12 @@
import org.apache.sandesha2.client.SandeshaClient;
import org.apache.sandesha2.client.SandeshaClientConstants;
import org.apache.sandesha2.client.SequenceReport;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNamespace;
public class AsyncPingClient {
private static final String applicationNamespaceName = "http://tempuri.org/";
- private static final String Ping = "Ping";
+ private static final String ping = "ping";
private static final String Text = "Text";
private String toIP = "127.0.0.1";
@@ -127,7 +125,7 @@
private static OMElement getPingOMBlock(String text) {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
- OMElement pingElem = fac.createOMElement(Ping, namespace);
+ OMElement pingElem = fac.createOMElement(ping, namespace);
OMElement textElem = fac.createOMElement(Text, namespace);
textElem.setText(text);
Modified: webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/RMSampleService.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/RMSampleService.java?rev=396253&r1=396252&r2=396253&view=diff
==============================================================================
--- webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/RMSampleService.java (original)
+++ webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/RMSampleService.java Sun Apr 23 04:09:26 2006
@@ -76,13 +76,4 @@
System.out.println("ping service got text:" + textValue);
}
-
- public OMElement EchoString(OMElement in) throws Exception {
- return echoString(in);
- }
-
- public void Ping(OMElement in) throws Exception {
- ping(in);
- }
-
}
Modified: webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/SyncEchoClient.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/SyncEchoClient.java?rev=396253&r1=396252&r2=396253&view=diff
==============================================================================
--- webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/SyncEchoClient.java (original)
+++ webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/SyncEchoClient.java Sun Apr 23 04:09:26 2006
@@ -19,6 +19,12 @@
import java.io.File;
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.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
@@ -27,14 +33,7 @@
import org.apache.axis2.client.async.Callback;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.sandesha2.Sandesha2Constants;
-import org.apache.sandesha2.client.SandeshaClient;
import org.apache.sandesha2.client.SandeshaClientConstants;
-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;
public class SyncEchoClient {
Modified: webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/SyncPingClient.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/SyncPingClient.java?rev=396253&r1=396252&r2=396253&view=diff
==============================================================================
--- webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/SyncPingClient.java (original)
+++ webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/SyncPingClient.java Sun Apr 23 04:09:26 2006
@@ -18,32 +18,28 @@
import java.io.File;
-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.axis2.AxisFault;
-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.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.context.MessageContextConstants;
-import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.client.SandeshaClient;
import org.apache.sandesha2.client.SandeshaClientConstants;
import org.apache.sandesha2.client.SandeshaListener;
-import org.apache.sandesha2.client.SandeshaClient;
import org.apache.sandesha2.client.SequenceReport;
-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;
public class SyncPingClient {
private static final String applicationNamespaceName = "http://tempuri.org/";
- private static final String Ping = "Ping";
+ private static final String ping = "ping";
private static final String Text = "Text";
private String toIP = "127.0.0.1";
@@ -135,7 +131,7 @@
private static OMElement getPingOMBlock(String text) {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
- OMElement pingElem = fac.createOMElement(Ping, namespace);
+ OMElement pingElem = fac.createOMElement(ping, namespace);
OMElement textElem = fac.createOMElement(Text, namespace);
textElem.setText(text);
Added: webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/UserguideEchoClient.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/UserguideEchoClient.java?rev=396253&view=auto
==============================================================================
--- webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/UserguideEchoClient.java (added)
+++ webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/UserguideEchoClient.java Sun Apr 23 04:09:26 2006
@@ -0,0 +1,113 @@
+/*
+ * 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 sandesha2.samples.userguide;
+
+import java.io.File;
+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.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.sandesha2.client.SandeshaClientConstants;
+
+public class UserguideEchoClient {
+
+ 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 toEPR = "http://127.0.0.1:8070/axis2/services/RMSampleService";
+
+ private static String CLIENT_REPO_PATH = "Full path to the Client Repo folder";
+
+ public static void main(String[] args) throws Exception {
+
+ String axis2_xml = CLIENT_REPO_PATH + File.separator +"client_axis2.xml";
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(CLIENT_REPO_PATH,axis2_xml);
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+
+ Options clientOptions = new Options ();
+ clientOptions.setTo(new EndpointReference (toEPR));
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+ clientOptions.setUseSeparateListener(true);
+ serviceClient.setOptions(clientOptions);
+
+ Callback callback1 = new TestCallback ("Callback 1");
+ serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo1","sequence1"),callback1);
+ Callback callback2 = new TestCallback ("Callback 2");
+ serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo2","sequence1"),callback2);
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ Callback callback3 = new TestCallback ("Callback 3");
+ serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo3","sequence1"),callback3);
+
+ while (!callback3.isComplete()) {
+ Thread.sleep(1000);
+ }
+
+ Thread.sleep(4000);
+ }
+
+ 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;
+ }
+
+ static class TestCallback extends Callback {
+
+ String name = null;
+ public TestCallback (String name) {
+ this.name = name;
+ }
+
+ public void onComplete(AsyncResult result) {
+ SOAPBody body = result.getResponseEnvelope().getBody();
+
+ OMElement echoStringResponseElem = body.getFirstChildWithName(new QName (applicationNamespaceName,echoStringResponse));
+ OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn));
+
+ 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();
+ }
+ }
+}
Added: webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/UserguidePingClient.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/UserguidePingClient.java?rev=396253&view=auto
==============================================================================
--- webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/UserguidePingClient.java (added)
+++ webservices/sandesha/trunk/samples/src/sandesha2/samples/userguide/UserguidePingClient.java Sun Apr 23 04:09:26 2006
@@ -0,0 +1,75 @@
+/*
+ * 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 sandesha2.samples.userguide;
+
+import java.io.File;
+
+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.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+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.sandesha2.client.SandeshaClientConstants;
+
+
+public class UserguidePingClient {
+
+ private static final String applicationNamespaceName = "http://tempuri.org/";
+ private static final String ping = "ping";
+ private static final String Text = "Text";
+ private static String toEPR = "http://127.0.0.1:8070/axis2/services/RMSampleService";
+
+ private static String CLIENT_REPO_PATH = "Full path to the Client Repo folder";
+
+ public static void main(String[] args) throws AxisFault {
+
+ String axis2_xml = CLIENT_REPO_PATH + File.separator + "client_axis2.xml";
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(CLIENT_REPO_PATH,axis2_xml);
+
+ Options clientOptions = new Options ();
+ clientOptions.setTo(new EndpointReference (toEPR));
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ clientOptions.setAction("urn:wsrm:Ping");
+ serviceClient.setOptions(clientOptions);
+
+ serviceClient.fireAndForget(getPingOMBlock("ping1"));
+ serviceClient.fireAndForget(getPingOMBlock("ping2"));
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ serviceClient.finalizeInvoke();
+ }
+
+ 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;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org