KickJava   Java API By Example, From Geeks To Geeks.

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


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 MicrosoftSyncPing {
31
32     private static String JavaDoc targetURL = "http://127.0.0.1:8070/SecureReliableMessaging/ReliableOneWay.svc";
33
34     public static void main(String JavaDoc[] args) {
35         System.out.println("Client started...... Synchronous - Microsoft ");
36         try {
37
38             Service service = new Service();
39             Call call = (Call) service.createCall();
40
41             SandeshaContext ctx = new SandeshaContext(Constants.SYNCHRONOUS);
42
43             ctx.setToURL("http://131.107.153.195/SecureReliableMessaging/ReliableOneWay.svc");
44             //We really do not want to send wsa:ReplyTo header for a synchronous operation.
45
//But Microsoft endpoint expects it for all the messages. So let's set that manually.
46
ctx.setReplyToURL(Constants.WSA.NS_ADDRESSING_ANONYMOUS);
47
48             ctx.initCall(call, targetURL, "urn:wsrm:Ping", Constants.ClientProperties.IN_ONLY);
49
50             call.setOperationName("Ping");
51
52             call.invoke(new Message(getSOAPEnvelope(1)));
53             call.invoke(new Message(getSOAPEnvelope(2)));
54             ctx.setLastMessage(call);
55             call.invoke(new Message(getSOAPEnvelope(3)));
56
57             ctx.endSequence();
58
59         } catch (Exception JavaDoc e) {
60             e.printStackTrace();
61         }
62     }
63
64     private static String JavaDoc getSOAPEnvelope(int i) {
65         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" +
66                 " <soapenv:Header>\n" + " </soapenv:Header>\n" + " <soapenv:Body>\n" + " <Ping xmlns=\"http://tempuri.org/\">\n" +
67                 " <Text>Ping Message Number " + i + "</Text>\n" + " </Ping>\n" + " </soapenv:Body></soapenv:Envelope>";
68
69     }
70 }
71
Popular Tags