KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.apache.sandesha.interop;
18
19 import org.apache.axis.Message;
20 import org.apache.axis.client.Call;
21 import org.apache.axis.client.Service;
22 import org.apache.sandesha.Constants;
23 import org.apache.sandesha.SandeshaContext;
24
25 /**
26  * Test client for Ping scenario for Microsoft.
27  *
28  * @author Jaliya Ekanyake
29  */

30 public class MicrosoftAsyncPing {
31
32     private static String JavaDoc sourceHost = "192.248.18.51"; //Change this to your public IP address
33
private static String JavaDoc sourcePort = "9070"; //Change this according to the listening port of the TCPMonitor in the
34
private static String JavaDoc targetURL = "http://127.0.0.1:8080/SecureReliableMessaging/ReliableOneWayDual.svc";
35
36     public static void main(String JavaDoc[] args) {
37         System.out.println("Client started...... Asynchronous - Microsoft");
38         try {
39
40
41             Service service = new Service();
42             Call call = (Call) service.createCall();
43
44             SandeshaContext ctx = new SandeshaContext();
45
46             ctx.setToURL("http://131.107.153.195/SecureReliableMessaging/ReliableOneWayDual.svc");
47             ctx.setFromURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
48             ctx.setAcksToURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
49             ctx.setFaultToURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
50             ctx.setReplyToURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
51
52             ctx.initCall(call, targetURL, "urn:wsrm:Ping", Constants.ClientProperties.IN_ONLY);
53
54             call.setOperationName("Ping");
55             call.invoke(new Message(getSOAPEnvelope(1)));
56             call.invoke(new Message(getSOAPEnvelope(2)));
57             ctx.setLastMessage(call);
58             call.invoke(new Message(getSOAPEnvelope(3)));
59
60             ctx.endSequence();
61
62         } catch (Exception JavaDoc e) {
63             e.printStackTrace();
64         }
65     }
66
67     private static String JavaDoc getSOAPEnvelope(int i) {
68         return "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">\n" +
69                 " <soapenv:Header>\n" + " </soapenv:Header>\n" + " <soapenv:Body>\n" + " <Ping xmlns=\"http://tempuri.org/\">\n" +
70                 " <Text>Ping Message Number " + i + "</Text>\n" + " </Ping>\n" + " </soapenv:Body></soapenv:Envelope>";
71     }
72 }
73
Popular Tags