1 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 ; 25 import java.net.ConnectException ; 26 import java.net.URL ; 27 28 public class TestCall extends TestCase { 29 public TestCall(String 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 41 public void testWeatherService() throws Exception { 42 try { 43 Call call = new Call(new URL ("http://live.capescience.com:80/ccx/GlobalWeather")); 44 call.setUseSOAPAction(true); 45 call.setSOAPActionURI("capeconnect:GlobalWeather:StationInfo#listCountries"); 46 call.setTimeout(new Integer (15*1000)); 47 call.setOperationName(new javax.xml.namespace.QName ("capeconnect:GlobalWeather:StationInfo", "listCountries")); 48 String [] c = (String []) call.invoke(new Object []{}); 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 || 55 fault.detail instanceof InterruptedIOException || 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 |