KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > sandesha > samples > EchoClientSyncAck


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.samples;
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.RMReport;
27 import org.apache.sandesha.SandeshaContext;
28
29 import javax.xml.namespace.QName JavaDoc;
30 import javax.xml.rpc.ParameterMode JavaDoc;
31
32 /**
33  * Test client for echoString scenario.
34  *
35  * @author Jaliya Ekanyake
36  */

37 public class EchoClientSyncAck {
38
39     private static String JavaDoc defaultServerPort = "8070";
40     private static String JavaDoc defaultClientPort = "9070";
41     private static String JavaDoc targetURL = "http://127.0.0.1:" + defaultServerPort +
42             "/axis/services/RMSampleService";
43
44
45     public static void main(String JavaDoc[] args) {
46
47         System.out.println("EchoClientSyncAck Started ........");
48
49         try {
50             UUIDGen uuidGen = UUIDGenFactory.getUUIDGen(); //Can use this for continuous testing.
51
String JavaDoc str = uuidGen.nextUUID();
52
53
54             Service service = new Service();
55             Call call = (Call) service.createCall();
56
57             SandeshaContext ctx = new SandeshaContext();
58
59             ctx.setAcksToURL(Constants.WSA.NS_ADDRESSING_ANONYMOUS);
60             ctx.setReplyToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
61             ctx.initCall(call, targetURL, "urn:wsrm:echoString", Constants.ClientProperties.IN_OUT);
62
63             call.setOperationName(new QName JavaDoc("http://tempuri.org/", "echoString"));
64
65             call.addParameter("arg1", XMLType.XSD_STRING, ParameterMode.IN);
66             call.addParameter("arg2", XMLType.XSD_STRING, ParameterMode.IN);
67             call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
68
69             String JavaDoc ret = (String JavaDoc) call.invoke(new Object JavaDoc[]{"Sandesha Echo 1", str});
70             System.out.println("The Response for First Messsage is :" + ret);
71
72             ret = (String JavaDoc) call.invoke(new Object JavaDoc[]{"Sandesha Echo 2", str});
73             System.out.println("The Response for Second Messsage is :" + ret);
74
75             //For last message.
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             RMReport report = ctx.endSequence();
81
82
83             if (report != null) {
84                 System.out.println("\n***********Printing RM Report***********");
85                 System.out.println("Is all messages acked - " + report.isAllAcked());
86                 System.out.println("No of response messages - " + report.getNumberOfReturnMessages());
87                 System.out.println("****************************************\n");
88             }
89
90
91         } catch (Exception JavaDoc e) {
92             e.printStackTrace();
93         }
94     }
95 }
96
Popular Tags