KickJava   Java API By Example, From Geeks To Geeks.

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


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