What s Next


Creating a Client for the New Service

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.

start example
 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();    }   }  } } 
end example

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.




Mastering Resin
Mastering Resin
ISBN: 0471431036
EAN: 2147483647
Year: 2002
Pages: 180

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net