/*
* Copyright (c) 2001 Ethan Cerami. All rights reserved.
* This code is from the book XML Web Services Essentials.
* It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied.
* You may study, use, and modify it for any non-commercial purpose.
* You may distribute it non-commercially as long as you retain this notice.
*/
package com.ecerami.wsdl;
import com.ecerami.wsdl.glue.*;
import java.io.IOException;
import electric.xml.io.Mappings;
import electric.xml.ParseException;
import electric.registry.RegistryException;
/**
* SOAP Invoker. Uses the XMethodsListingsServiceHelper to invoke
* SOAP service. All other .java files are automatically generated by GLUE.
*/
public class Invoke_Weather {
/**
* Get Weather Summary via SOAP
*/
public WeatherSummary getWeatherSummary (String airportCode)
throws Exception {
// Load Java <--> XML Mapping
Mappings.readMappings("AirportWeather.map");
// Invoke Service
IAirportWeather weather = AirportWeatherHelper.bind();
WeatherSummary summary = weather.getSummary(airportCode);
return summary;
}
/**
* Main Method
*/
public static void main (String[] args) throws Exception {
Invoke_Weather weather = new Invoke_Weather();
WeatherSummary summary = weather.getWeatherSummary ("KJFK");
System.out.println ("Weather Summary:");
System.out.println ("Location: "+summary.location);
System.out.println ("Humidiy: "+summary.humidity);
System.out.println ("Visibility: "+summary.visibility);
System.out.println ("Temperature: "+summary.temp);
}
}
|