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 2004/05/03 14:32:36 UTC

cvs commit: ws-fx/sandesha/samples/org/apache/sandesha/samples/interop EchoStringService.java PingService.java Scenario_1_1_Client.java Scenario_2_2_Client.java

jaliya      2004/05/03 05:32:36

  Added:       sandesha/samples/org/apache/sandesha/samples/interop
                        EchoStringService.java PingService.java
                        Scenario_1_1_Client.java Scenario_2_2_Client.java
  Log:
  Add samples directory to sandesha holding test client and services
  
  Revision  Changes    Path
  1.1                  ws-fx/sandesha/samples/org/apache/sandesha/samples/interop/EchoStringService.java
  
  Index: EchoStringService.java
  ===================================================================
  /*
   * Created on May 3, 2004
   *
   * To change the template for this generated file go to
   * Window>Preferences>Java>Code Generation>Code and Comments
   */
  package org.apache.sandesha.samples.interop;
  
  import java.util.HashMap;
  import java.util.Map;
  
  /**
   * @author SNimalan
   *
   * To change the template for this generated type comment go to
   * Window>Preferences>Java>Code Generation>Code and Comments
   */
  public class EchoStringService {
  	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;
  	}
  }
  
  
  
  1.1                  ws-fx/sandesha/samples/org/apache/sandesha/samples/interop/PingService.java
  
  Index: PingService.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.interop;
  
  
  /**
   * @author
   * Amila Navarathna<br>
   * Jaliya Ekanayaka<br>
   * Sudar Nimalan<br>
   * (Apache Sandesha Project)
   *
   */
  public class PingService {
      public void Ping(String arg) {
          System.out.println("Request from Client : " + arg);
      }
  
  }
  
  
  
  1.1                  ws-fx/sandesha/samples/org/apache/sandesha/samples/interop/Scenario_1_1_Client.java
  
  Index: Scenario_1_1_Client.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.interop;
  
  
  /**
   * @author
   * Amila Navarathna<br>
   * Jaliya Ekanayaka<br>
   * Sudar Nimalan<br>
   * (Apache Sandesha Project)
   *
   */
  
  import javax.xml.namespace.QName;
  import javax.xml.rpc.ParameterMode;
  
  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;
  
  public class Scenario_1_1_Client {
      public static void main(String[] args) {
          System.out.println("Client started......");
          try {
  
              Service service = new Service();
  
              Call call = (Call) service.createCall();
              if(args[0].equals("")){
              	System.out.println("Pass Target End Point Address as a Parametter");
              	throw new Exception("Target End Point Address did not Set");
              }
              
              call.setTargetEndpointAddress(args[0]);
              call.setOperationName(new QName("PingService", "Ping"));
              call.addParameter("Text", XMLType.XSD_STRING, ParameterMode.IN);
              call.setReturnType(XMLType.AXIS_VOID);
  
              UUIDGen uuidGen = UUIDGenFactory.getUUIDGen();
                      
              call.setProperty(Constants.CLIENT_SEQUENCE_IDENTIFIER,"uuid:" + uuidGen.nextUUID());
  			call.setProperty(Constants.CLIENT_ONE_WAY_INVOKE,(new Boolean(true)));
  			call.setProperty(Constants.CLIENT_RESPONSE_EXPECTED,(new Boolean(false)));
  			call.setProperty(Constants.CLIENT_CREATE_SEQUENCE,(new Boolean(false)));
  
              call.invoke(new Object[] {"Ping 1"});
              call.invoke(new Object[] {"Ping 2"});
              call.setLastMessage(true);
              call.invoke(new Object[] {"Ping 3"});
  
          } catch (Exception e) {
              System.err.println(e.toString());
          }
      }
  }
  
  
  
  
  1.1                  ws-fx/sandesha/samples/org/apache/sandesha/samples/interop/Scenario_2_2_Client.java
  
  Index: Scenario_2_2_Client.java
  ===================================================================
  /*
   * Created on May 3, 2004
   *
   * To change the template for this generated file go to
   * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
   */
  package org.apache.sandesha.samples.interop;
  
  import javax.xml.namespace.QName;
  import javax.xml.rpc.ParameterMode;
  
  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;
  
  /**
   * @author SNimalan
   *
   * To change the template for this generated type comment go to
   * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
   */
  public class Scenario_2_2_Client {
  	public static void main(String[] args) {
  			System.out.println("Client started......");
  			try {
  
  				Service service = new Service();
  
  				Call call = (Call) service.createCall();
  				if(args[0].equals("")){
  					System.out.println("Pass Target End Point Address as a Parametter");
  					throw new Exception("Target End Point Address did not Set");
  				}
              
  				call.setTargetEndpointAddress(args[0]);
  				call.setOperationName(new QName("EchoStringService", "echoString"));
  				call.addParameter("Text", XMLType.XSD_STRING, ParameterMode.IN);
  				call.addParameter("Sequence", XMLType.XSD_STRING, ParameterMode.IN);
  				call.setReturnType(XMLType.SOAP_STRING);
  
  				UUIDGen uuidGen = UUIDGenFactory.getUUIDGen();
                      
  				call.setProperty(Constants.CLIENT_SEQUENCE_IDENTIFIER,"uuid:" + uuidGen.nextUUID());
  				call.setProperty(Constants.CLIENT_ONE_WAY_INVOKE,(new Boolean(true)));
  				call.setProperty(Constants.CLIENT_RESPONSE_EXPECTED,(new Boolean(false)));
  				call.setProperty(Constants.CLIENT_CREATE_SEQUENCE,(new Boolean(false)));
  				
  				String seq=uuidGen.nextUUID();
  				System.out.println(call.invoke(new Object[] {"Hello",seq}));				
  				System.out.println(call.invoke(new Object[] {"World",seq}));
  				call.setLastMessage(true);
  				System.out.println(call.invoke(new Object[] {"Bye",seq}));
  				
  				
  
  			} catch (Exception e) {
  				System.err.println(e.toString());
  			}
  		}
  	}