KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > wsdl > terra > TerraServiceTestCase


1 /**
2  * TerraServiceTestCase.java
3  *
4  * This file was auto-generated from WSDL
5  * by the Apache Axis WSDL2Java emitter.
6  */

7
8 package test.wsdl.terra;
9
10 import org.apache.axis.AxisFault;
11
12 import java.net.ConnectException JavaDoc;
13
14 public class TerraServiceTestCase extends junit.framework.TestCase {
15     public TerraServiceTestCase(java.lang.String JavaDoc name) {
16         super(name);
17     }
18
19     public void test11TerraServiceSoapGetPlaceList() {
20         TerraServiceSoap binding;
21         try {
22             binding = new TerraServiceLocator().getTerraServiceSoap();
23         }
24         catch (javax.xml.rpc.ServiceException JavaDoc jre) {
25             throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
26         }
27         assertTrue("binding is null", binding != null);
28
29         try {
30             ArrayOfPlaceFacts value = null;
31             value = binding.getPlaceList(new java.lang.String JavaDoc("Boston"), 5, true);
32             PlaceFacts[] facts = value.getPlaceFacts();
33             for(int i=0;i<facts.length;i++){
34                 System.out.println("City :" + facts[i].getPlace().getCity());
35                 System.out.println("State :" + facts[i].getPlace().getState());
36                 System.out.println("Country :" + facts[i].getPlace().getCountry());
37                 System.out.println("Lat :" + facts[i].getCenter().getLon());
38                 System.out.println("Long :" + facts[i].getCenter().getLat());
39                 System.out.println("Theme :" + facts[i].getAvailableThemeMask());
40                 System.out.println("PlaceType :" + facts[i].getPlaceTypeId().getValue());
41                 System.out.println("Population:" + facts[i].getPopulation());
42                 System.out.println("---------------------------");
43             }
44         }
45         catch (java.rmi.RemoteException JavaDoc re) {
46             if (re instanceof AxisFault) {
47                 AxisFault fault = (AxisFault) re;
48                 if (fault.detail instanceof ConnectException JavaDoc ||
49                     fault.getFaultCode().getLocalPart().equals("HTTP")) {
50                     System.err.println("TerraService HTTP error: " + fault);
51                     return;
52                 }
53             }
54             throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re);
55         }
56     }
57 }
58
Popular Tags