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/03/18 13:44:29 UTC
svn commit: r386843 - in
/webservices/sandesha/trunk/interop/src/org/apache/sandesha2: ./
wsrm_2006_02/
Author: chamikara
Date: Sat Mar 18 04:44:26 2006
New Revision: 386843
URL: http://svn.apache.org/viewcvs?rev=386843&view=rev
Log:
test clients to tes OASIS 2006.02 scenario doc.
Added:
webservices/sandesha/trunk/interop/src/org/apache/sandesha2/InteropClientAPI.java
webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/
webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_1.java
webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_2.java
webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_3.java
webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_4.java
webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_2_1.java
webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_2_2.java
webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_2_3.java
Added: webservices/sandesha/trunk/interop/src/org/apache/sandesha2/InteropClientAPI.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/interop/src/org/apache/sandesha2/InteropClientAPI.java?rev=386843&view=auto
==============================================================================
--- webservices/sandesha/trunk/interop/src/org/apache/sandesha2/InteropClientAPI.java (added)
+++ webservices/sandesha/trunk/interop/src/org/apache/sandesha2/InteropClientAPI.java Sat Mar 18 04:44:26 2006
@@ -0,0 +1,203 @@
+/*
+ * Copyright 1999-2004 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;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.sandesha2.client.Sandesha2ClientAPI;
+import org.apache.sandesha2.client.reports.SequenceReport;
+import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+import org.apache.sandesha2.storage.beans.SequencePropertyBean;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.wsrm.AckRequested;
+import org.apache.sandesha2.wsrm.CloseSequence;
+import org.apache.sandesha2.wsrm.Identifier;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.soap.SOAP12Constants;
+import org.apache.ws.commons.soap.SOAPEnvelope;
+import org.apache.ws.commons.soap.SOAPFactory;
+import org.apache.ws.commons.soap.impl.llom.soap11.SOAP11Factory;
+import org.apache.ws.commons.soap.impl.llom.soap12.SOAP12Factory;
+
+/**
+ * Contains logic to remove all the storad data of a sequence.
+ * Methods of this are called by sending side and the receiving side when appropriate
+ *
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+
+public class InteropClientAPI {
+
+ public static String generateInternalSequenceIDForTheClientSide (String toEPR,String sequenceKey) {
+ return SandeshaUtil.getInternalSequenceID(toEPR,sequenceKey);
+ }
+
+ //gives the out sequenceID if CS/CSR exchange is done. Otherwise a SandeshaException
+ public static String getSequenceID (String to,String sequenceKey,ServiceClient serviceClient,ConfigurationContext configurationContext) throws AxisFault {
+
+ String internalSequenceID = generateInternalSequenceIDForTheClientSide(to,sequenceKey);
+
+ SequenceReport sequenceReport = Sandesha2ClientAPI.getOutgoingSequenceReport(to,sequenceKey , configurationContext);
+ if (sequenceReport==null)
+ throw new SandeshaException ("Cannot get a sequence report from the given data");
+
+ if (sequenceReport.getSequenceStatus()!=SequenceReport.SEQUENCE_STATUS_ESTABLISHED) {
+ throw new SandeshaException ("Sequence is not in a active state. Either create sequence response has not being received or sequence has been terminated," +
+ " cannot get sequenceID");
+ }
+
+ StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext);
+ SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
+
+ SequencePropertyBean sequenceIDBean = seqPropMgr.retrieve(internalSequenceID,Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);
+ if (sequenceIDBean==null)
+ throw new SandeshaException ("SequenceIdBean is not set");
+
+ String sequenceID = sequenceIDBean.getValue();
+ return sequenceID;
+ }
+
+ public static void sendAckRequest (String toEPR, String sequenceKey, ServiceClient serviceClient, ConfigurationContext configurationContext) throws AxisFault {
+
+ Options options = serviceClient.getOptions();
+ String rmSpecVersion = (String) options.getProperty(Sandesha2ClientAPI.RM_SPEC_VERSION);
+ if (rmSpecVersion==null)
+ rmSpecVersion = Sandesha2Constants.SPEC_VERSIONS.WSRM;
+
+ if (Sandesha2Constants.SPEC_VERSIONS.WSRM.equals(rmSpecVersion)) {
+ throw new SandeshaException ("Empty AckRequest messages can only be sent with the WSRX spec");
+ }
+
+ String internalSequenceID = SandeshaUtil.getInternalSequenceID(toEPR,sequenceKey);
+
+ SequenceReport sequenceReport = Sandesha2ClientAPI.getOutgoingSequenceReport(internalSequenceID,configurationContext);
+ if (sequenceReport==null)
+ throw new SandeshaException ("Cannot generate the sequence report for the given internalSequenceID");
+ if (sequenceReport.getSequenceStatus()!=SequenceReport.SEQUENCE_STATUS_ESTABLISHED)
+ throw new SandeshaException ("Canot send the ackRequest message since it is not active");
+
+ StorageManager storageManager = SandeshaUtil
+ .getSandeshaStorageManager(configurationContext);
+
+ SequencePropertyBeanMgr seqPropMgr = storageManager
+ .getSequencePropretyBeanMgr();
+
+ String outSequenceID = getSequenceID(toEPR,sequenceKey,serviceClient,configurationContext);
+
+ String soapNamespaceURI = options.getSoapVersionURI();
+ SOAPFactory factory = null;
+ SOAPEnvelope dummyEnvelope = null;
+ if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(soapNamespaceURI)) {
+ factory = new SOAP11Factory ();
+ dummyEnvelope = factory.getDefaultEnvelope();
+ }else {
+ factory = new SOAP12Factory ();
+ dummyEnvelope = factory.getDefaultEnvelope();
+ }
+
+ String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(rmSpecVersion);
+
+ AckRequested ackRequested = new AckRequested (factory,rmNamespaceValue);
+ Identifier identifier = new Identifier (factory,rmNamespaceValue);
+ identifier.setIndentifer(outSequenceID);
+ ackRequested.setIdentifier(identifier);
+
+
+ ackRequested.toSOAPEnvelope(dummyEnvelope);
+
+ OMElement ackRequestedHeaderBlock = dummyEnvelope.getHeader().getFirstChildWithName(new QName (rmNamespaceValue,Sandesha2Constants.WSRM_COMMON.ACK_REQUESTED));
+
+ String oldAction = options.getAction();
+// String oldSOAPAction = options.getSoapAction();
+ options.setAction(SpecSpecificConstants.getAckRequestAction(rmSpecVersion));
+// options.setAction(SpecSpecificConstants.getAckRequestSOAPAction(rmSpecVersion));
+
+ System.out.println("Snding ack Rek");
+ serviceClient.addHeader(ackRequestedHeaderBlock);
+
+ serviceClient.fireAndForget(null);
+ serviceClient.removeHeaders();
+ options.setAction(oldAction);
+// options.setSoapAction(oldSOAPAction);
+
+ }
+
+ public static void closeSequence (String toEPR, String sequenceKey, ServiceClient serviceClient,ConfigurationContext configurationContext) throws AxisFault {
+
+ String internalSequenceID = SandeshaUtil.getInternalSequenceID(toEPR,sequenceKey);
+
+ SequenceReport sequenceReport = Sandesha2ClientAPI.getOutgoingSequenceReport(internalSequenceID,configurationContext);
+ if (sequenceReport==null)
+ throw new SandeshaException ("Cannot generate the sequence report for the given internalSequenceID");
+ if (sequenceReport.getSequenceStatus()!=SequenceReport.SEQUENCE_STATUS_ESTABLISHED)
+ throw new SandeshaException ("Canot close the sequence since it is not active");
+
+ String sequenceID = getSequenceID(toEPR,sequenceKey,serviceClient,configurationContext);
+ if (sequenceID==null)
+ throw new SandeshaException ("Cannot find the sequenceID");
+
+ Options options = serviceClient.getOptions();
+
+ String rmSpecVersion = (String) options.getProperty(Sandesha2ClientAPI.RM_SPEC_VERSION);
+
+ if (rmSpecVersion==null)
+ rmSpecVersion = SpecSpecificConstants.getDefaultSpecVersion ();
+
+ if (!SpecSpecificConstants.isSequenceClosingAllowed (rmSpecVersion))
+ throw new SandeshaException ("This rm version does not allow sequence closing");
+
+ StorageManager storageManager = SandeshaUtil
+ .getSandeshaStorageManager(configurationContext);
+
+ SequencePropertyBeanMgr seqPropMgr = storageManager
+ .getSequencePropretyBeanMgr();
+
+
+ String oldAction = options.getAction();
+
+ options.setAction(SpecSpecificConstants.getCloseSequenceAction (rmSpecVersion));
+
+ SOAPEnvelope dummyEnvelope = null;
+ SOAPFactory factory = null;
+ String soapNamespaceURI = options.getSoapVersionURI();
+ if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(soapNamespaceURI)) {
+ factory = new SOAP12Factory ();
+ dummyEnvelope = factory.getDefaultEnvelope();
+ }else {
+ factory = new SOAP11Factory ();
+ dummyEnvelope = factory.getDefaultEnvelope();
+ }
+
+ String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(rmSpecVersion);
+
+ CloseSequence closeSequence = new CloseSequence (factory,rmNamespaceValue);
+ Identifier identifier = new Identifier (factory,rmNamespaceValue);
+ identifier.setIndentifer(sequenceID);
+ closeSequence.setIdentifier(identifier);
+
+ closeSequence.toSOAPEnvelope(dummyEnvelope);
+ serviceClient.fireAndForget(dummyEnvelope.getBody().getFirstChildWithName(new QName (rmNamespaceValue,Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE)));
+
+ options.setAction(oldAction);
+ }
+}
Added: webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_1.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_1.java?rev=386843&view=auto
==============================================================================
--- webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_1.java (added)
+++ webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_1.java Sat Mar 18 04:44:26 2006
@@ -0,0 +1,138 @@
+/*
+ * 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.wsrm_2006_02;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+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.axis2.context.MessageContextConstants;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.client.Sandesha2ClientAPI;
+import org.apache.sandesha2.client.reports.SequenceReport;
+import org.apache.ws.commons.om.OMAbstractFactory;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMFactory;
+import org.apache.ws.commons.om.OMNamespace;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+public class Scenario_1_1 {
+
+ private static final String applicationNamespaceName = "http://tempuri.org/";
+ private static final String Ping = "Ping";
+ private static final String Text = "Text";
+
+ private String toIP = "127.0.0.1";
+
+ private String toPort = "8080";
+ private String transportToPort = "8070";
+
+ private String toEPR = "http://" + toIP + ":" + toPort + "/axis2/services/RMInteropService";
+
+ private String transportToEPR = "http://" + toIP + ":" + transportToPort + "/axis2/services/RMInteropService";
+
+ 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 AxisFault {
+
+ String axisClientRepo = null;
+ if (args!=null && args.length>0)
+ axisClientRepo = args[0];
+
+ if (axisClientRepo!=null && !"".equals(axisClientRepo)) {
+ AXIS2_CLIENT_PATH = axisClientRepo;
+ SANDESHA2_HOME = "";
+ }
+
+ new Scenario_1_1 ().run();
+ }
+
+ private void run () throws AxisFault {
+
+ if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+ System.out.println("ERROR: Please change <SANDESHA2_HOME> to your Sandesha2 installation directory.");
+ return;
+ }
+
+ String axis2_xml = AXIS2_CLIENT_PATH + "axis2.xml";
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+ Options clientOptions = new Options ();
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
+ clientOptions.setProperty(Options.COPY_PROPERTIES, new Boolean (true));
+ clientOptions.setTo(new EndpointReference (toEPR));
+
+ String sequenceKey = "sequence1";
+ clientOptions.setProperty(Sandesha2ClientAPI.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(Sandesha2ClientAPI.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.WSRX); //uncomment this to send the messages according to the WSRX spec.
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+
+ serviceClient.engageModule(new QName ("sandesha2")); //engaging the sandesha2 module.
+
+ serviceClient.setOptions(clientOptions);
+
+ serviceClient.fireAndForget(getPingOMBlock("ping1"));
+ serviceClient.fireAndForget(getPingOMBlock("ping2"));
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ SequenceReport sequenceReport = null;
+ boolean complete = false;
+ while (!complete) {
+ sequenceReport = Sandesha2ClientAPI.getOutgoingSequenceReport(toEPR,sequenceKey,configContext);
+ if (sequenceReport!=null && sequenceReport.getCompletedMessages().size()==3)
+ complete = true;
+ else {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+
+ Sandesha2ClientAPI.terminateSequence(toEPR,sequenceKey,serviceClient,configContext);
+ 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;
+ }
+
+}
Added: webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_2.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_2.java?rev=386843&view=auto
==============================================================================
--- webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_2.java (added)
+++ webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_2.java Sat Mar 18 04:44:26 2006
@@ -0,0 +1,160 @@
+/*
+ * 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.wsrm_2006_02;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+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.axis2.context.MessageContextConstants;
+import org.apache.sandesha2.InteropClientAPI;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.client.Sandesha2ClientAPI;
+import org.apache.sandesha2.client.reports.SequenceReport;
+import org.apache.ws.commons.om.OMAbstractFactory;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMFactory;
+import org.apache.ws.commons.om.OMNamespace;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+public class Scenario_1_2 {
+
+ private static final String applicationNamespaceName = "http://tempuri.org/";
+ private static final String Ping = "Ping";
+ private static final String Text = "Text";
+
+ private String toIP = "127.0.0.1";
+
+ private String toPort = "8080";
+ private String transportToPort = "8070";
+
+ private String toEPR = "http://" + toIP + ":" + toPort + "/axis2/services/RMInteropService";
+
+ private String transportToEPR = "http://" + toIP + ":" + transportToPort + "/axis2/services/RMInteropService";
+
+ 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 AxisFault {
+
+ String axisClientRepo = null;
+ if (args!=null && args.length>0)
+ axisClientRepo = args[0];
+
+ if (axisClientRepo!=null && !"".equals(axisClientRepo)) {
+ AXIS2_CLIENT_PATH = axisClientRepo;
+ SANDESHA2_HOME = "";
+ }
+
+
+ new Scenario_1_2 ().run();
+ }
+
+ private void run () throws AxisFault {
+
+ if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+ System.out.println("ERROR: Please change <SANDESHA2_HOME> to your Sandesha2 installation directory.");
+ return;
+ }
+
+ String axis2_xml = AXIS2_CLIENT_PATH + "axis2.xml";
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+ Options clientOptions = new Options ();
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
+ clientOptions.setProperty(Options.COPY_PROPERTIES, new Boolean (true));
+ clientOptions.setTo(new EndpointReference (toEPR));
+
+ String sequenceKey = "sequence1";
+ clientOptions.setProperty(Sandesha2ClientAPI.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(Sandesha2ClientAPI.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.WSRX); //uncomment this to send the messages according to the WSRX spec.
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+
+ serviceClient.engageModule(new QName ("sandesha2")); //engaging the sandesha2 module.
+
+ serviceClient.setOptions(clientOptions);
+
+ clientOptions.setProperty(Sandesha2ClientAPI.DUMMY_MESSAGE,Sandesha2ClientAPI.VALUE_TRUE);
+ clientOptions.setProperty(Sandesha2ClientAPI.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping31"));
+
+ clientOptions.setProperty(Sandesha2ClientAPI.DUMMY_MESSAGE,Sandesha2ClientAPI.VALUE_FALSE);
+
+ SequenceReport sequenceReport = null;
+
+ boolean established = false;
+ while (!established) {
+ sequenceReport = Sandesha2ClientAPI.getOutgoingSequenceReport(toEPR,sequenceKey,configContext);
+ if (sequenceReport!=null && sequenceReport.getSequenceStatus()>=SequenceReport.SEQUENCE_STATUS_ESTABLISHED)
+ established = true;
+ else {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+
+ InteropClientAPI.sendAckRequest(toEPR,sequenceKey,serviceClient,configContext);
+
+ Sandesha2ClientAPI.terminateSequence(toEPR,sequenceKey,serviceClient,configContext);
+
+ boolean terminated = false;
+ while (!terminated) {
+ sequenceReport = Sandesha2ClientAPI.getOutgoingSequenceReport(toEPR,sequenceKey,configContext);
+ if (sequenceReport!=null && sequenceReport.getSequenceStatus()==SequenceReport.SEQUENCE_STATUS_TERMINATED)
+ terminated = true;
+ else {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+
+ 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;
+ }
+
+}
Added: webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_3.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_3.java?rev=386843&view=auto
==============================================================================
--- webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_3.java (added)
+++ webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_3.java Sat Mar 18 04:44:26 2006
@@ -0,0 +1,145 @@
+/*
+ * 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.wsrm_2006_02;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+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.axis2.context.MessageContextConstants;
+import org.apache.sandesha2.InteropClientAPI;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.client.Sandesha2ClientAPI;
+import org.apache.sandesha2.client.reports.SequenceReport;
+import org.apache.ws.commons.om.OMAbstractFactory;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMFactory;
+import org.apache.ws.commons.om.OMNamespace;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+public class Scenario_1_3 {
+
+ private static final String applicationNamespaceName = "http://tempuri.org/";
+ private static final String Ping = "Ping";
+ private static final String Text = "Text";
+
+ private String toIP = "127.0.0.1";
+
+ private String toPort = "8080";
+ private String transportToPort = "8070";
+
+ private String toEPR = "http://" + toIP + ":" + toPort + "/axis2/services/RMInteropService";
+ private String transportToEPR = "http://" + toIP + ":" + transportToPort + "/axis2/services/RMInteropService";
+
+ 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 AxisFault {
+
+ String axisClientRepo = null;
+ if (args!=null && args.length>0)
+ axisClientRepo = args[0];
+
+ if (axisClientRepo!=null && !"".equals(axisClientRepo)) {
+ AXIS2_CLIENT_PATH = axisClientRepo;
+ SANDESHA2_HOME = "";
+ }
+
+ new Scenario_1_3 ().run();
+ }
+
+ private void run () throws AxisFault {
+
+ if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+ System.out.println("ERROR: Please change <SANDESHA2_HOME> to your Sandesha2 installation directory.");
+ return;
+ }
+
+ String axis2_xml = AXIS2_CLIENT_PATH + "axis2.xml";
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+ Options clientOptions = new Options ();
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
+ clientOptions.setProperty(Options.COPY_PROPERTIES, new Boolean (true));
+ clientOptions.setTo(new EndpointReference (toEPR));
+
+ String sequenceKey = "sequence1";
+ clientOptions.setProperty(Sandesha2ClientAPI.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(Sandesha2ClientAPI.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.WSRX); //uncomment this to send the messages according to the WSRX spec.
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+
+ serviceClient.engageModule(new QName ("sandesha2")); //engaging the sandesha2 module.
+
+ serviceClient.setOptions(clientOptions);
+
+ clientOptions.setProperty(Sandesha2ClientAPI.MESSAGE_NUMBER,new Long(1));
+ serviceClient.fireAndForget(getPingOMBlock("ping1"));
+
+ clientOptions.setProperty(Sandesha2ClientAPI.MESSAGE_NUMBER,new Long(3));
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ boolean complete = false;
+ while (!complete) {
+ SequenceReport sequenceReport = Sandesha2ClientAPI.getOutgoingSequenceReport(toEPR,sequenceKey,configContext);
+ if (sequenceReport!=null && sequenceReport.getCompletedMessages().size()==2)
+ complete = true;
+ else {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+
+ InteropClientAPI.closeSequence(toEPR,sequenceKey,serviceClient,configContext);
+
+ clientOptions.setProperty(Sandesha2ClientAPI.MESSAGE_NUMBER,new Long(4));
+ serviceClient.fireAndForget(getPingOMBlock("ping4"));
+
+
+ Sandesha2ClientAPI.terminateSequence(toEPR,sequenceKey,serviceClient,configContext);
+ 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;
+ }
+
+}
Added: webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_4.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_4.java?rev=386843&view=auto
==============================================================================
--- webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_4.java (added)
+++ webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_1_4.java Sat Mar 18 04:44:26 2006
@@ -0,0 +1,171 @@
+/*
+ * 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.wsrm_2006_02;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.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.Sandesha2Constants;
+import org.apache.sandesha2.client.Sandesha2ClientAPI;
+import org.apache.sandesha2.client.reports.SequenceReport;
+import org.apache.ws.commons.om.OMAbstractFactory;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMFactory;
+import org.apache.ws.commons.om.OMNamespace;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+public class Scenario_1_4 {
+
+ private static final String applicationNamespaceName = "http://tempuri.org/";
+
+ private static final String Ping = "Ping";
+
+ private static final String Text = "Text";
+
+ private String toIP = "127.0.0.1";
+
+ private String toPort = "8080";
+
+ private String transportToPort = "8070";
+
+ private String ackIP = "127.0.0.1";
+
+ private String ackPort = "9070";
+
+ private String toEPR = "http://" + toIP + ":" + toPort + "/axis2/services/RMInteropService";
+
+ private String transportToEPR = "http://" + toIP + ":" + transportToPort
+ + "/axis2/services/RMInteropService";
+
+ 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 AxisFault {
+
+ String axisClientRepo = null;
+ if (args != null && args.length > 0)
+ axisClientRepo = args[0];
+
+ if (axisClientRepo != null && !"".equals(axisClientRepo)) {
+ AXIS2_CLIENT_PATH = axisClientRepo;
+ SANDESHA2_HOME = "";
+ }
+
+ new Scenario_1_4().run();
+ }
+
+ private void run() throws AxisFault {
+
+ if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)) {
+ System.out
+ .println("ERROR: Please change <SANDESHA2_HOME> to your Sandesha2 installation directory.");
+ return;
+ }
+
+ String axis2_xml = AXIS2_CLIENT_PATH + "axis2.xml";
+ ConfigurationContext configContext = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,
+ axis2_xml);
+ Options clientOptions = new Options();
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,
+ transportToEPR);
+
+ clientOptions.setProperty(Options.COPY_PROPERTIES, new Boolean(true));
+ clientOptions.setTo(new EndpointReference(toEPR));
+
+ ServiceClient serviceClient = new ServiceClient(configContext, null);
+
+ String replyAddress = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress() + "/" + ServiceClient.ANON_OUT_ONLY_OP;
+
+ clientOptions.setProperty(Sandesha2ClientAPI.AcksTo,replyAddress);
+ clientOptions.setReplyTo(new EndpointReference (replyAddress));
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+
+ String sequenceKey = "sequence1";
+ clientOptions.setProperty(Sandesha2ClientAPI.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(Sandesha2ClientAPI.RM_SPEC_VERSION,
+ Sandesha2Constants.SPEC_VERSIONS.WSRX); // uncomment this to
+ // send the messages
+ // according to the WSRX
+ // spec.
+
+ serviceClient.engageModule(new QName("sandesha2")); // engaging the
+ // sandesha2 module.
+
+ serviceClient.setOptions(clientOptions);
+
+ serviceClient.fireAndForget(getPingOMBlock("ping1"));
+ serviceClient.fireAndForget(getPingOMBlock("ping2"));
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ boolean complete = false;
+ while (!complete) {
+ SequenceReport sequenceReport = Sandesha2ClientAPI.getOutgoingSequenceReport(
+ toEPR, sequenceKey, configContext);
+ if (sequenceReport!=null && sequenceReport.getCompletedMessages().size()==3)
+ complete = true;
+ else {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+
+ Sandesha2ClientAPI.terminateSequence(toEPR,sequenceKey,serviceClient,configContext);
+// 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;
+ }
+}
Added: webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_2_1.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_2_1.java?rev=386843&view=auto
==============================================================================
--- webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_2_1.java (added)
+++ webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_2_1.java Sat Mar 18 04:44:26 2006
@@ -0,0 +1,201 @@
+/*
+ * 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.wsrm_2006_02;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+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.Sandesha2ClientAPI;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.ws.commons.om.OMAbstractFactory;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMFactory;
+import org.apache.ws.commons.om.OMNamespace;
+import org.apache.ws.commons.soap.SOAP12Constants;
+import org.apache.ws.commons.soap.SOAPBody;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+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 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";
+
+ private String toEPR = "http://" + toIP + ":" + toPort + "/axis2/services/RMInteropService";
+
+ private String transportToEPR = "http://" + toIP + ":" + transportToPort + "/axis2/services/RMInteropService";
+
+ //private String acksToEPR = "http://" + ackIP + ":" + ackPort + "/axis2/services/" + "__ANONYMOUS_SERVICE__";
+
+ 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 = "";
+ }
+
+ new Scenario_2_1 ().run();
+ }
+
+ 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 + "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 (toEPR));
+
+ String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+ clientOptions.setProperty(Sandesha2ClientAPI.AcksTo,acksTo);
+
+ String sequenceKey = "sequence4";
+ clientOptions.setProperty(Sandesha2ClientAPI.SEQUENCE_KEY,sequenceKey);
+
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
+
+// clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE); //uncomment this to send messages without chunking.
+
+ clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); //uncomment this to send messages in SOAP 1.2
+
+ clientOptions.setProperty(Sandesha2ClientAPI.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.WSRX); //uncomment this to send the messages according to the WSRX spec.
+
+ clientOptions.setProperty(Sandesha2ClientAPI.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);
+
+ serviceClient.setOptions(clientOptions);
+ serviceClient.engageModule(new QName ("sandesha2")); //engaging the sandesha2 module.
+
+ 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);
+ }
+
+
+ Sandesha2ClientAPI.terminateSequence(toEPR,sequenceKey,serviceClient,configContext);
+// serviceClient.finalizeInvoke();
+
+ }
+
+ 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();
+ }
+ }
+
+
+}
Added: webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_2_2.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_2_2.java?rev=386843&view=auto
==============================================================================
--- webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_2_2.java (added)
+++ webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_2_2.java Sat Mar 18 04:44:26 2006
@@ -0,0 +1,199 @@
+/*
+ * 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.wsrm_2006_02;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+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.Sandesha2ClientAPI;
+import org.apache.ws.commons.om.OMAbstractFactory;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMFactory;
+import org.apache.ws.commons.om.OMNamespace;
+import org.apache.ws.commons.soap.SOAP12Constants;
+import org.apache.ws.commons.soap.SOAPBody;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+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 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";
+
+ private String toEPR = "http://" + toIP + ":" + toPort + "/axis2/services/RMInteropService";
+
+ private String transportToEPR = "http://" + toIP + ":" + transportToPort + "/axis2/services/RMInteropService";
+
+ //private String acksToEPR = "http://" + ackIP + ":" + ackPort + "/axis2/services/" + "__ANONYMOUS_SERVICE__";
+
+ 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 = "";
+ }
+
+ new Scenario_2_2 ().run();
+ }
+
+ 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 + "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 (toEPR));
+
+ String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+ clientOptions.setProperty(Sandesha2ClientAPI.AcksTo,acksTo);
+
+ String sequenceKey = "sequence4";
+ clientOptions.setProperty(Sandesha2ClientAPI.SEQUENCE_KEY,sequenceKey);
+
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
+
+// clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE); //uncomment this to send messages without chunking.
+
+ clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); //uncomment this to send messages in SOAP 1.2
+
+ clientOptions.setProperty(Sandesha2ClientAPI.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.WSRX); //uncomment this to send the messages according to the WSRX spec.
+
+// clientOptions.setProperty(Sandesha2ClientAPI.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);
+
+ serviceClient.setOptions(clientOptions);
+ serviceClient.engageModule(new QName ("sandesha2")); //engaging the sandesha2 module.
+
+ 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);
+ }
+
+
+ Sandesha2ClientAPI.terminateSequence(toEPR,sequenceKey,serviceClient,configContext);
+
+ }
+
+ 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();
+ }
+ }
+
+
+}
Added: webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_2_3.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_2_3.java?rev=386843&view=auto
==============================================================================
--- webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_2_3.java (added)
+++ webservices/sandesha/trunk/interop/src/org/apache/sandesha2/wsrm_2006_02/Scenario_2_3.java Sat Mar 18 04:44:26 2006
@@ -0,0 +1,199 @@
+/*
+ * 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.wsrm_2006_02;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+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.Sandesha2ClientAPI;
+import org.apache.ws.commons.om.OMAbstractFactory;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMFactory;
+import org.apache.ws.commons.om.OMNamespace;
+import org.apache.ws.commons.soap.SOAP12Constants;
+import org.apache.ws.commons.soap.SOAPBody;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+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 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";
+
+ private String toEPR = "http://" + toIP + ":" + toPort + "/axis2/services/RMInteropService";
+
+ private String transportToEPR = "http://" + toIP + ":" + transportToPort + "/axis2/services/RMInteropService";
+
+ //private String acksToEPR = "http://" + ackIP + ":" + ackPort + "/axis2/services/" + "__ANONYMOUS_SERVICE__";
+
+ 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 = "";
+ }
+
+ new Scenario_2_3 ().run();
+ }
+
+ 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 + "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 (toEPR));
+
+ String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+ clientOptions.setProperty(Sandesha2ClientAPI.AcksTo,acksTo);
+
+ String sequenceKey = "sequence4";
+ clientOptions.setProperty(Sandesha2ClientAPI.SEQUENCE_KEY,sequenceKey);
+
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
+
+// clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE); //uncomment this to send messages without chunking.
+
+ clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); //uncomment this to send messages in SOAP 1.2
+
+ clientOptions.setProperty(Sandesha2ClientAPI.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.WSRX); //uncomment this to send the messages according to the WSRX spec.
+
+ clientOptions.setProperty(Sandesha2ClientAPI.OFFERED_SEQUENCE_ID,"a"); //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);
+ serviceClient.engageModule(new QName ("sandesha2")); //engaging the sandesha2 module.
+
+ 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);
+ }
+
+
+ Sandesha2ClientAPI.terminateSequence(toEPR,sequenceKey,serviceClient,configContext);
+// serviceClient.finalizeInvoke();
+ }
+
+ 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();
+ }
+ }
+
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org