KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > client > TestCall


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of 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,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package test.client;
17
18 import junit.framework.Test;
19 import junit.framework.TestCase;
20 import junit.framework.TestSuite;
21 import org.apache.axis.AxisFault;
22 import org.apache.axis.client.Call;
23
24 import java.io.InterruptedIOException JavaDoc;
25 import java.net.ConnectException JavaDoc;
26 import java.net.URL JavaDoc;
27
28 public class TestCall extends TestCase {
29     public TestCall(String JavaDoc name) {
30         super(name);
31     }
32
33     public static Test suite() {
34         return new TestSuite(TestCall.class);
35     }
36
37     protected void setup() {
38     }
39
40     /* Test case for Bug 23031 - No deserializer found for ns1:ArrayOfstring */
41     public void testWeatherService() throws Exception JavaDoc {
42         try {
43             Call call = new Call(new URL JavaDoc("http://live.capescience.com:80/ccx/GlobalWeather"));
44             call.setUseSOAPAction(true);
45             call.setSOAPActionURI("capeconnect:GlobalWeather:StationInfo#listCountries");
46             call.setTimeout(new Integer JavaDoc(15*1000));
47             call.setOperationName(new javax.xml.namespace.QName JavaDoc("capeconnect:GlobalWeather:StationInfo", "listCountries"));
48             String JavaDoc[] c = (String JavaDoc[]) call.invoke(new Object JavaDoc[]{});
49             System.out.println(c.length);
50             for (int i = 0; i < c.length; i++) {
51                 System.out.println(c[i]);
52             }
53         } catch (AxisFault fault) {
54             if (fault.detail instanceof ConnectException JavaDoc ||
55                     fault.detail instanceof InterruptedIOException JavaDoc ||
56                     (fault.getFaultString().indexOf("Connection timed out") != -1) ||
57                     fault.getFaultCode().getLocalPart().equals("HTTP")) {
58                 System.err.println("getTemp HTTP error: " + fault);
59                 return;
60             }
61             throw fault;
62         }
63     }
64 }
65
Popular Tags