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 ja...@apache.org on 2005/06/11 12:00:05 UTC

cvs commit: ws-fx/sandesha/samples/org/apache/sandesha/samples AsyncPingClient.java EchoClientAsyncAck.java EchoClientSyncAck.java RMSampleService.java SyncPingClient.java

jaliya      2005/06/11 03:00:05

  Added:       sandesha/samples/org/apache/sandesha/samples
                        AsyncPingClient.java EchoClientAsyncAck.java
                        EchoClientSyncAck.java RMSampleService.java
                        SyncPingClient.java
  Log:
  Samples were added
  
  Revision  Changes    Path
  1.1                  ws-fx/sandesha/samples/org/apache/sandesha/samples/AsyncPingClient.java
  
  Index: AsyncPingClient.java
  ===================================================================
  /*
  * 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.sandesha.samples;
  
  import org.apache.axis.client.Call;
  import org.apache.axis.client.Service;
  import org.apache.axis.encoding.XMLType;
  import org.apache.sandesha.Constants;
  import org.apache.sandesha.RMReport;
  import org.apache.sandesha.SandeshaContext;
  
  import javax.xml.namespace.QName;
  import javax.xml.rpc.ParameterMode;
  
  /**
   * Test client for Ping scenario, with asynchronous <wsrm:AcksTo>
   *
   * @auther Jaliya Ekanyake
   */
  public class AsyncPingClient {
      private static String defaultServerPort = "8070";
      private static String defaultClientPort = "9070";
      private static String targetURL = "http://127.0.0.1:" + defaultServerPort +
              "/axis/services/RMSampleService";
  
      public static void main(String[] args) {
          System.out.println("Client started...... Asynchronous ");
          try {
  
              Service service = new Service();
              Call call = (Call) service.createCall();
  
              SandeshaContext ctx = new SandeshaContext();
              ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:ping",
                      Constants.ClientProperties.IN_ONLY);
              ctx.setAcksToUrl(call,
                      "http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
  
              call.setOperationName(new QName("http://tempuri.org", "Ping"));
              call.addParameter("Text", XMLType.XSD_STRING, ParameterMode.IN);
  
              call.invoke(new Object[]{"Ping Message Number One"});
              call.invoke(new Object[]{"Ping Message Number Two"});
              ctx.setLastMessage(call);
              call.invoke(new Object[]{"Ping Message Number Three"});
  
              RMReport report = ctx.endSequence(call);
  
  
              if (report != null) {
                  System.out.println("\n***********Printing RM Report***********");
                  System.out.println("Were all messages acked     - " + report.isAllAcked());
                  System.out.println("****************************************\n");
              }
  
  
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  
  
  
  1.1                  ws-fx/sandesha/samples/org/apache/sandesha/samples/EchoClientAsyncAck.java
  
  Index: EchoClientAsyncAck.java
  ===================================================================
  /*
  * 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.sandesha.samples;
  
  import org.apache.axis.client.Call;
  import org.apache.axis.client.Service;
  import org.apache.axis.components.uuid.UUIDGen;
  import org.apache.axis.components.uuid.UUIDGenFactory;
  import org.apache.axis.encoding.XMLType;
  import org.apache.sandesha.Constants;
  import org.apache.sandesha.RMReport;
  import org.apache.sandesha.SandeshaContext;
  
  import javax.xml.namespace.QName;
  import javax.xml.rpc.ParameterMode;
  
  public class EchoClientAsyncAck {
  
      private static String defaultServerPort = "8070";
      private static String defaultClientPort = "9070";
      private static String targetURL = "http://127.0.0.1:" + defaultServerPort +
              "/axis/services/RMSampleService";
  
      public static void main(String[] args) {
  
          System.out.println("EchoClientAsyncAck Started ........");
  
          try {
              UUIDGen uuidGen = UUIDGenFactory.getUUIDGen(); //Can use this for continuous testing.
              String str = uuidGen.nextUUID();
  
              Service service = new Service();
              Call call = (Call) service.createCall();
  
              SandeshaContext ctx = new SandeshaContext();
              ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:echoString",
                      Constants.ClientProperties.IN_OUT);
              ctx.setAcksToUrl(call,
                      "http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
              ctx.setReplyToUrl(call,
                      "http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
              ctx.setSendOffer(call);
  
              call.setOperationName(new QName("http://tempuri.org/", "echoString"));
  
              call.addParameter("arg1", XMLType.XSD_STRING, ParameterMode.IN);
              call.addParameter("arg2", XMLType.XSD_STRING, ParameterMode.IN);
              call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
  
              String ret = (String) call.invoke(new Object[]{"Sandesha Echo 1", str});
              System.out.println("The Response for First Messsage is  :" + ret);
  
              ret = (String) call.invoke(new Object[]{"Sandesha Echo 2", str});
              System.out.println("The Response for Second Messsage is  :" + ret);
  
              ctx.setLastMessage(call);
              ret = (String) call.invoke(new Object[]{"Sandesha Echo 3", str});
              System.out.println("The Response for Third Messsage is  :" + ret);
  
              RMReport report = ctx.endSequence(call);
  
  
              if (report != null) {
                  System.out.println("\n***********Printing RM Report***********");
                  System.out.println("Were all messages add     - " + report.isAllAcked());
                  System.out.println(
                          "No of response messages   - " + report.getNumberOfReturnMessages());
                  System.out.println("****************************************\n");
              }
             
  
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  
  
  
  1.1                  ws-fx/sandesha/samples/org/apache/sandesha/samples/EchoClientSyncAck.java
  
  Index: EchoClientSyncAck.java
  ===================================================================
  /*
  * 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.sandesha.samples;
  
  import org.apache.axis.client.Call;
  import org.apache.axis.client.Service;
  import org.apache.axis.encoding.XMLType;
  import org.apache.axis.components.uuid.UUIDGenFactory;
  import org.apache.axis.components.uuid.UUIDGen;
  import org.apache.sandesha.*;
  
  import javax.xml.namespace.QName;
  import javax.xml.rpc.ParameterMode;
  /**
   * Test client for echoString scenario.
   *
   * @auther Jaliya Ekanyake
   */
  public class EchoClientSyncAck {
  
      private static String defaultServerPort = "8070";
      private static String defaultClientPort = "9070";
      private static String targetURL = "http://127.0.0.1:" + defaultServerPort +
              "/axis/services/RMSampleService";
  
      public static void main(String[] args) {
  
          System.out.println("EchoClientSyncAck Started ........");
  
          try {
              UUIDGen uuidGen = UUIDGenFactory.getUUIDGen(); //Can use this for continuous testing.
              String str = uuidGen.nextUUID();
  
  
              Service service = new Service();
              Call call = (Call) service.createCall();
  
              SandeshaContext ctx = new SandeshaContext();
              ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:echoString",
                      Constants.ClientProperties.IN_OUT);
  
              ctx.setAcksToUrl(call, Constants.WSA.NS_ADDRESSING_ANONYMOUS);
              ctx.setReplyToUrl(call,
                      "http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
  
             call.setOperationName(new QName("http://tempuri.org/", "echoString"));
  
              call.addParameter("arg1", XMLType.XSD_STRING, ParameterMode.IN);
              call.addParameter("arg2", XMLType.XSD_STRING, ParameterMode.IN);
              call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
  
                              String ret = (String) call.invoke(new Object[]{"Sandesha Echo 1", str});
              System.out.println("The Response for First Messsage is  :" + ret);
  
              ret = (String) call.invoke(new Object[]{"Sandesha Echo 2", str});
              System.out.println("The Response for Second Messsage is  :" + ret);
  
              //For last message.
           ctx.setLastMessage(call);
              ret = (String) call.invoke(new Object[]{"Sandesha Echo 3", str});
              System.out.println("The Response for Third Messsage is  :" + ret);
  
              RMReport report = ctx.endSequence(call);
  
  
                         if (report != null) {
                             System.out.println("\n***********Printing RM Report***********");
                             System.out.println("Were all messages add     - " + report.isAllAcked());
                             System.out.println(
                                     "No of response messages   - " + report.getNumberOfReturnMessages());
                             System.out.println("****************************************\n");
                         }
  
              
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  
  
  
  1.1                  ws-fx/sandesha/samples/org/apache/sandesha/samples/RMSampleService.java
  
  Index: RMSampleService.java
  ===================================================================
  /*
  * 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.sandesha.samples;
  
  import java.util.HashMap;
  import java.util.Map;
  
  /**
   * This is the service that is used for the interop testing. Two operations, ping and echoString
   * are defined as per the interop scenarios.
   *
   * @auther Jaliya Ekanayake
   */
  public class RMSampleService {
      private static Map sequences = new HashMap();
  
      public String echoString(String text, String sequence) {
  
          if (sequences.get(sequence) != null) {
              text = (String) sequences.get(sequence) + text;
              sequences.put(sequence, new String(text));
          } else {
              sequences.put(sequence, (new String(text)));
  
          }
          return text;
      }
  
      public void ping(String text) {
          //Just accept the message and do some processing
      }
  }
  
  
  
  1.1                  ws-fx/sandesha/samples/org/apache/sandesha/samples/SyncPingClient.java
  
  Index: SyncPingClient.java
  ===================================================================
  /*
  * 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.sandesha.samples;
  
  import org.apache.axis.client.Call;
  import org.apache.axis.client.Service;
  import org.apache.axis.encoding.XMLType;
  import org.apache.sandesha.Constants;
  import org.apache.sandesha.RMReport;
  import org.apache.sandesha.SandeshaContext;
  
  import javax.xml.namespace.QName;
  import javax.xml.rpc.ParameterMode;
  
  /**
   * Test client for Ping scenario with synchronous invocation. No client side listener will start
   * and all the communications will happen synchronously.
   *
   * @auther Jaliya Ekanyake
   */
  public class SyncPingClient {
  
      private static String defaultServerPort = "8070";
  
      private static String targetURL = "http://127.0.0.1:" + defaultServerPort +
              "/axis/services/RMSampleService";
  
      public static void main(String[] args) {
          System.out.println("Client started...... Synchronous ");
          try {
  
  
              Service service = new Service();
              Call call = (Call) service.createCall();
  
              SandeshaContext ctx = new SandeshaContext();
              ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:Ping",
                      Constants.ClientProperties.IN_ONLY);
              ctx.setSynchronous(call);
           
              call.setOperationName(new QName("http://tempuri.org/", "Ping"));
              call.addParameter("arg1", XMLType.XSD_STRING, ParameterMode.IN);
          
              call.invoke(new Object[]{"Ping Message Number One"});
              call.invoke(new Object[]{"Ping Message Number Two"});
              ctx.setLastMessage(call);
              call.invoke(new Object[]{"Ping Message Number Three"});
  
              RMReport report = ctx.endSequence(call);
  
  
              if (report != null) {
                  System.out.println("\n***********Printing RM Report***********");
                  System.out.println("Were all messages acked     - " + report.isAllAcked());
                  System.out.println("****************************************\n");
              }
  
          } catch (Exception e) {
              //System.err.println(e.toString());
              e.printStackTrace();
          }
      }
  }