KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > sandesha > interop > IBMEcho


1 /*
2 * Copyright 1999-2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 *
16 */

17
18 package org.apache.sandesha.interop;
19
20 import org.apache.axis.client.Call;
21 import org.apache.axis.client.Service;
22 import org.apache.axis.components.uuid.UUIDGen;
23 import org.apache.axis.components.uuid.UUIDGenFactory;
24 import org.apache.axis.encoding.XMLType;
25 import org.apache.sandesha.Constants;
26 import org.apache.sandesha.SandeshaContext;
27
28 import javax.xml.namespace.QName JavaDoc;
29 import javax.xml.rpc.ParameterMode JavaDoc;
30
31 /**
32  * Test client for echoString scenario for IBM.
33  *
34  * @author Jaliya Ekanyake
35  */

36 public class IBMEcho {
37     private static String JavaDoc sourceHost = "192.248.18.51"; //Change this to your public IP address
38
private static String JavaDoc targetURL = "http://127.0.0.1:8080/wsrm/services/rmDemos";
39     private static String JavaDoc sourcePort = "9070"; //Change this according to the listening port of the TCPMonitor in the
40
//client side.
41

42     public static void main(String JavaDoc[] args) {
43
44         System.out.println("Client started...... Asynchronous EchoString - IBM");
45
46         UUIDGen uuidGen = UUIDGenFactory.getUUIDGen(); //Can use this for continuous testing.
47
String JavaDoc str = uuidGen.nextUUID();
48
49         try {
50             Service service = new Service();
51             Call call = (Call) service.createCall();
52
53             SandeshaContext ctx = new SandeshaContext();
54
55
56             ctx.setToURL("http://wsi.alphaworks.ibm.com:8080/wsrm/services/rmDemos");
57             ctx.setFaultToURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
58             ctx.setAcksToURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
59             ctx.setFromURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
60             ctx.setReplyToURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
61
62             ctx.initCall(call, targetURL, "urn:wsrm:echoString", Constants.ClientProperties.IN_OUT);
63
64             call.setOperationName(new QName JavaDoc("http://tempuri.org/", "echoString"));
65
66             call.addParameter("Text", XMLType.XSD_STRING, ParameterMode.IN);
67             call.addParameter("Sequence", XMLType.XSD_STRING, ParameterMode.IN);
68             call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
69
70             String JavaDoc ret = (String JavaDoc) call.invoke(new Object JavaDoc[]{"Sandesha Echo 1", str});
71             System.out.println("The Response for First Messsage is :" + ret);
72
73             ret = (String JavaDoc) call.invoke(new Object JavaDoc[]{"Sandesha Echo 2", str});
74             System.out.println("The Response for Second Messsage is :" + ret);
75
76             ctx.setLastMessage(call);
77             ret = (String JavaDoc) call.invoke(new Object JavaDoc[]{"Sandesha Echo 3", str});
78             System.out.println("The Response for Third Messsage is :" + ret);
79
80             ctx.endSequence();
81         } catch (Exception JavaDoc e) {
82             e.printStackTrace();
83         }
84     }
85 }
86
Popular Tags