Listing 1: THE SIGNATURE OF THE STATES BEAN
package forecast.beans;
public class States {
public String[] getStates() {...}
}
package forecast.beans;
public class Cities {
public void setState(String state) {...}
public String getState() {...}
public void setCities(String[] cities) {...}
public String[] getCities() {...}
public void addCity(String city) {...}
}
package forecast.beans;
public class Forecast {
public void setPeriod(String p) {...}
public String getPeriod() {...}
public void setForecast(String f) {...}
public String getForecast() {...}
}
package forecast.beans;
public class Forecasts {
public void setLocation(String l) {...}
public String getLocation() {...}
public void setIssued(String i) {...}
public String getIssued() {...}
public void setForecasts(Forecast[] f) {...}
public Forecast[] getForecasts() {...}
public void addForecast(Forecast f) {...}
}
Listing 2: THE SIGNATURE OF THE WEATHERFORECAST BEAN
package forecast;
import forecast.beans.*;
public class WeatherForecast {
public States getStates() {...}
public Cities getCities(String state) {...}
public Forecasts getForecast(String state, String city) {...}
}
Listing 3: excerpt from weatherforecast.wsdl
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="WeatherForecast"
targetNamespace="http://forecast.wsdl/WeatherForecast/"
...
xmlns:xsd1="http://beans.forecast/">
<import location="beans/Cities.xsd"
namespace="http://beans.forecast/"/>
<import location="beans/Forecasts.xsd"
namespace="http://beans.forecast/"/>
<import location="beans/Forecast.xsd"
namespace="http://beans.forecast/"/>
<import location="beans/States.xsd"
namespace="http://beans.forecast/"/>
<message name="getForecastRequest">
<part name="state" type="xsd:string"/>
<part name="city" type="xsd:string"/>
</message>
<message name="getForecastResponse">
<part name="result" type="xsd1:Forecasts"/>
</message>
...
<portType name="WeatherForecast">
<operation name="getForecast" parameterOrder="state city">
<input message="tns:getForecastRequest" name="getForecastRequest"/>
<output message="tns:getForecastResponse" name="getForecastResponse"/>
</operation>
...
</portType>
</definitions>
Listing 4: the schema definition
corresponding to the forecast javabean
<?xml version="1.0" encoding="UTF-8"?>
<schema attributeFormDefault="qualified"
elementFormDefault="unqualified"
targetNamespace="http://beans.forecast/"
xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd1="http://beans.forecast/">
<complexType name="Forecast">
<all>
<element name="forecast" nillable="true" type="string"/>
<element name="period" nillable="true" type="string"/>
</all>
</complexType>
</schema>
Listing 5: Excerpts of the schema
definition corresponding to the
Forecasts JavaBean
<?xml version="1.0" encoding="UTF-8"?>
<schema attributeFormDefault="qualified"
elementFormDefault="unqualified"
targetNamespace="http://beans.forecast/"
...
xmlns:xsd1="http://beans.forecast/">
<include schemaLocation="Forecast.xsd"/>
...
<complexType name="ArrayOfForecast">
<complexContent>
<restriction base="soapenc:Array">
<sequence/>
<attribute ref="soapenc:arrayType"wsdl:arrayType="xsd1:Forecast[]"/>
</restriction>
</complexContent>
</complexType>
<complexType name="Forecasts">
<all>
<element name="location" nillable="true" type="string"/>
<element name="forecasts" nillable="true" type="xsd1:ArrayOfForecast"/>
<element name="issued" nillable="true" type="string"/>
</all>
</complexType>
</schema
Listing 6: Excerpts from the binding file, WeatherForecastBinding.wsdl
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="WeatherForecastBinding"
targetNamespace="http://forecast.wsdl/WeatherForecastBinding/
xmlns:interface="http://forecast.wsdl/WeatherForecast/"
...
xmlns:tns="http://forecast.wsdl/WeatherForecastBinding/">
<import location="WeatherForecast.wsdl"
namespace="http://forecast.wsdl/WeatherForecast/"/>
<binding name="WeatherForecastBinding"
type="interface:WeatherForecast">
<soap:binding style="rpc"transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getForecast">
<soap:operation soapAction="" style="rpc"/>
<input name="getForecastRequest">
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://tempuri.org/forecast.WeatherForecast"
parts="state city" use="encoded"/>
</input>
<output name="getForecastResponse">
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://tempuri.org/forecast.WeatherForecast" use="encoded"/>
</output>
</operation>
...
</binding>
</definitions>
Listing 7: The WSDL file, WeatherForecast Service.wsdl
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="WeatherForecastService"
targetNamespace="http://forecast.wsdl/WeatherForecastService/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:binding="http://forecast.wsdl/WeatherForecastBinding/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://forecast.wsdl/WeatherForecastService/">
<import location="WeatherForecastBinding.wsdl" namespace="http://forecast.wsdl/WeatherForecastBinding/"/>
<service name="WeatherForecastService">
<port binding="binding:WeatherForecastBinding" name="WeatherForecastPort">
<soap:address location="http://localhost:9080/WForecast/servlet/rpcrouter"/>
</port>
</service>
</definitions>
Listing 8: Excerpts of the WSAD-generated proxy
package proxy.soap;
...
public class WeatherForecastProxy {
public synchronized void setEndPoint(URL url) {...}
public synchronized URL getEndPoint() {...}
public synchronized forecast.beans.Cities getCities(java.lang.String state) {...}
public synchronized forecast.beans.Forecasts
getForecast(java.lang.String state,
java.lang.String city) {...}
public synchronized forecast.beans.States getStates() {...}
}
Listing 9: Excerpts from forecast. beans.Forecasts.
package forecast.beans;
import com.ibm.etools.xsd.bean.runtime.AnyType;
...
public class Forecasts extends AnyType {
public Forecasts() {
addElement("location", java.lang.String.class);
addElement("forecasts", Forecast[].class);
addElement("issued", java.lang.String.class);
}
public String getLocation() {
return (String)this.basicGet("location", 0);
}
public void setLocation(String location) {
this.basicSet("location", 0, location);
}
public Forecast[] getForecasts() {
return (Forecast[])this.basicGet("forecasts", 0);
}
public void setForecasts(Forecast[] forecasts) {
this.basicSet("forecasts", 0, forecasts);
}
public String getIssued() {
return (String)this.basicGet("issued", 0);
}
public void setIssued(String issued) {
this.basicSet("issued", 0, issued);
}
}
Listing 10: TestWF, a simple test prograM
public class TestWF {
public static void main(String[] args) {
try {
proxy.soap.WeatherForecastProxy wf = new proxy.soap.WeatherForecastProxy();
forecast.beans.States states = wf.getStates();
String[] a = states.getStates();
System.out.println("The first state: "+ a[0]);
forecast.beans.Cities cities = wf.getCities("AK");
a = cities.getCities();
System.out.println("The first city: "+ a[0]);
forecast.beans.Forecasts forecasts = wf.getForecast("AK", "Nome");
forecast.beans.Forecast[] fA = forecasts.getForecasts();
System.out.println("The first forecast: "+ fA[0].getPeriod()
+ " - " + fA[0].getForecast());
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
}