KickJava   Java API By Example, From Geeks To Geeks.

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


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.encoding.XMLType;
23 import org.apache.sandesha.Constants;
24 import org.apache.sandesha.RMReport;
25 import org.apache.sandesha.SandeshaContext;
26
27 import javax.xml.namespace.QName JavaDoc;
28 import javax.xml.rpc.ParameterMode JavaDoc;
29
30 /**
31  * Test client for Ping scenario with synchronous invocation. No client side listener will start
32  * and all the communications will happen synchronously.
33  *
34  * @author Jaliya Ekanyake
35  */

36 public class SyncPingClient {
37
38     private static String JavaDoc defaultServerPort = "8070";
39
40     private static String JavaDoc targetURL = "http://127.0.0.1:" + defaultServerPort +
41             "/axis/services/RMSampleService";
42
43     public static void main(String JavaDoc[] args) {
44         System.out.println("Client started...... Synchronous ");
45         try {
46
47
48             Service service = new Service();
49             Call call = (Call) service.createCall();
50
51             SandeshaContext ctx = new SandeshaContext(Constants.SYNCHRONOUS);
52             ctx.initCall(call, targetURL, "urn:wsrm:Ping",
53                     Constants.ClientProperties.IN_ONLY);
54
55             call.setOperationName(new QName JavaDoc("http://tempuri.org/", "Ping"));
56             call.addParameter("arg1", XMLType.XSD_STRING, ParameterMode.IN);
57
58             call.invoke(new Object JavaDoc[]{"Ping Message Number One"});
59             call.invoke(new Object JavaDoc[]{"Ping Message Number Two"});
60             ctx.setLastMessage(call);
61             call.invoke(new Object JavaDoc[]{"Ping Message Number Three"});
62
63             RMReport report = ctx.endSequence();
64
65
66             if (report != null) {
67                 System.out.println("\n***********Printing RM Report***********");
68                 System.out.println("Is all messages acked - " + report.isAllAcked());
69                 System.out.println("****************************************\n");
70             }
71
72         } catch (Exception JavaDoc e) {
73             e.printStackTrace();
74         }
75     }
76 }
77
Popular Tags