|
Using the code from the BasicAPI application as an outline, you can create a client for your weather service. The code in Listing 8.4 shows how to access the service.
Listing 8.4: The CAService client.
import com.caucho.burlap.client.BurlapProxyFactory; import java.net.MalformedURLException; import weather.WeatherServiceAPI; public class CAClient { static String url = "http://localhost:8080/weather/ /WeatherService"; public static void main(String[] args) { WeatherServiceAPI weather = null; BurlapProxyFactory factory = new BurlapProxyFactory(); try { weather = (WeatherServiceAPI) factory.create(WeatherServiceAPI.class, url); } catch (MalformedURLException e) { System.out.println("Bad URL"); } if (weather != null) { try { System.out.println("Rain In Denver = " + weather.getRainTotals("Denver")); System.out.println("Current Weather In Atlanta = " + weather.getCurrentWeather("Atlanta")); } catch (Exception e) { e.printStackTrace(); } } } }
As you can see, this code is similar to what you wrote in the BasicAPI client. Instead of using BasicAPI, though, you use the WeatherServiceAPI interface.
|