In this section, I will go over the interface and the parameters required for the remote method.
There are many free web services on the Internet (XMethods, WebserviceX.net, and so on). I will use one of the WebserviceX.net services for this article (see Figure 1).
Figure 1. Weather Forecast application relying on Flash Media Server web services to display the information
The end user simply submits a five-digit ZIP code to the service. There's no real error handling built in. When results are displayed, the Next and Prev buttons step the user through the upcoming days in the forecast.
Because there is a limit to the amount of data that Flash Media Server can receive from a web service, you may get mixed results with this weather forcast application. This web service provides a seven-day forecast but you will notice that, in most cases, you get a five-day forecast due to this limitation. The other result you may receive is an "Unable to connect to endpoint" message.
Note: If you do receive an "Unable to connect to endpoint" message, enter a new ZIP code and try again. There is no need to recompile the client application or unload the server ASC file. Alternate between ZIP codes 33021, 77077, 33004, 33309, 77079, 94105, 10286, and 97070. Of course, you can use your own ZIP code—just remember that this is a free service and is not always available.
Point your browser to the following URL, which shows the XML structure definition for the Weather Forecast WSDL (see Listing 1). You should be able to see other methods that you could use, like GetWeatherByPlaceName, which requires a parameter PlaceName of type string:
For this exercise, I will focus on GetWeatherByZipCode, which requires a parameter of type string.
Listing 1. Weather Forecast WSDL
<wsdl:definitions targetNamespace="http://www.webservicex.net">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://www.webservicex.net">
<s:element name="GetWeatherByZipCode">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ZipCode" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetWeatherByZipCodeResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="GetWeatherByZipCodeResult" type="tns:WeatherForecasts"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="WeatherForecasts">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="Latitude" type="s:float"/>
<s:element minOccurs="1" maxOccurs="1" name="Longitude" type="s:float"/>
<s:element minOccurs="1" maxOccurs="1" name="AllocationFactor" type="s:float"/>
<s:element minOccurs="0" maxOccurs="1" name="FipsCode" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="PlaceName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="StateCode" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Status" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Details" type="tns:ArrayOfWeatherData"/>
</s:sequence>
</s:complexType>
<s:complexType name="ArrayOfWeatherData">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="WeatherData" type="tns:WeatherData"/>
</s:sequence>
</s:complexType>
<s:complexType name="WeatherData">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Day" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="WeatherImage" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="MaxTemperatureF" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="MinTemperatureF" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="MaxTemperatureC" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="MinTemperatureC" type="s:string"/>
</s:sequence>
</s:complexType>
<s:element name="GetWeatherByPlaceName">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="PlaceName" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetWeatherByPlaceNameResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="GetWeatherByPlaceNameResult" type="tns:WeatherForecasts"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="WeatherForecasts" type="tns:WeatherForecasts"/>
</s:schema>
</wsdl:types>
<wsdl:message name="GetWeatherByZipCodeSoapIn">
<wsdl:part name="parameters" element="tns:GetWeatherByZipCode"/>
</wsdl:message>
<wsdl:message name="GetWeatherByZipCodeSoapOut">
<wsdl:part name="parameters" element="tns:GetWeatherByZipCodeResponse"/>
</wsdl:message>
<wsdl:message name="GetWeatherByPlaceNameSoapIn">
<wsdl:part name="parameters" element="tns:GetWeatherByPlaceName"/>
</wsdl:message>
<wsdl:message name="GetWeatherByPlaceNameSoapOut">
<wsdl:part name="parameters" element="tns:GetWeatherByPlaceNameResponse"/>
</wsdl:message>
<wsdl:message name="GetWeatherByZipCodeHttpGetIn">
<wsdl:part name="ZipCode" type="s:string"/>
</wsdl:message>
<wsdl:message name="GetWeatherByZipCodeHttpGetOut">
<wsdl:part name="Body" element="tns:WeatherForecasts"/>
</wsdl:message>
<wsdl:message name="GetWeatherByPlaceNameHttpGetIn">
<wsdl:part name="PlaceName" type="s:string"/>
</wsdl:message>
<wsdl:message name="GetWeatherByPlaceNameHttpGetOut">
<wsdl:part name="Body" element="tns:WeatherForecasts"/>
</wsdl:message>
<wsdl:message name="GetWeatherByZipCodeHttpPostIn">
<wsdl:part name="ZipCode" type="s:string"/>
</wsdl:message>
<wsdl:message name="GetWeatherByZipCodeHttpPostOut">
<wsdl:part name="Body" element="tns:WeatherForecasts"/>
</wsdl:message>
<wsdl:message name="GetWeatherByPlaceNameHttpPostIn">
<wsdl:part name="PlaceName" type="s:string"/>
</wsdl:message>
<wsdl:message name="GetWeatherByPlaceNameHttpPostOut">
<wsdl:part name="Body" element="tns:WeatherForecasts"/>
</wsdl:message>
<wsdl:portType name="WeatherForecastSoap">
<wsdl:operation name="GetWeatherByZipCode">
<documentation>
Get one week weather forecast for a valid Zip Code(USA)
</documentation>
<wsdl:input message="tns:GetWeatherByZipCodeSoapIn"/>
<wsdl:output message="tns:GetWeatherByZipCodeSoapOut"/>
</wsdl:operation>
<wsdl:operation name="GetWeatherByPlaceName">
<documentation>
Get one week weather forecast for a place name(USA)
</documentation>
<wsdl:input message="tns:GetWeatherByPlaceNameSoapIn"/>
<wsdl:output message="tns:GetWeatherByPlaceNameSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="WeatherForecastHttpGet">
<wsdl:operation name="GetWeatherByZipCode">
<documentation>
Get one week weather forecast for a valid Zip Code(USA)
</documentation>
<wsdl:input message="tns:GetWeatherByZipCodeHttpGetIn"/>
<wsdl:output message="tns:GetWeatherByZipCodeHttpGetOut"/>
</wsdl:operation>
<wsdl:operation name="GetWeatherByPlaceName">
<documentation>
Get one week weather forecast for a place name(USA)
</documentation>
<wsdl:input message="tns:GetWeatherByPlaceNameHttpGetIn"/>
<wsdl:output message="tns:GetWeatherByPlaceNameHttpGetOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="WeatherForecastHttpPost">
<wsdl:operation name="GetWeatherByZipCode">
<documentation>
Get one week weather forecast for a valid Zip Code(USA)
</documentation>
<wsdl:input message="tns:GetWeatherByZipCodeHttpPostIn"/>
<wsdl:output message="tns:GetWeatherByZipCodeHttpPostOut"/>
</wsdl:operation>
<wsdl:operation name="GetWeatherByPlaceName">
<documentation>
Get one week weather forecast for a place name(USA)
</documentation>
<wsdl:input message="tns:GetWeatherByPlaceNameHttpPostIn"/>
<wsdl:output message="tns:GetWeatherByPlaceNameHttpPostOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WeatherForecastSoap" type="tns:WeatherForecastSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="GetWeatherByZipCode">
<soap:operation soapAction="http://www.webservicex.net/GetWeatherByZipCode" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetWeatherByPlaceName">
<soap:operation soapAction="http://www.webservicex.net/GetWeatherByPlaceName" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="WeatherForecastHttpGet" type="tns:WeatherForecastHttpGet">
<http:binding verb="GET"/>
<wsdl:operation name="GetWeatherByZipCode">
<http:operation location="/GetWeatherByZipCode"/>
<wsdl:input>
<http:urlEncoded/>
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetWeatherByPlaceName">
<http:operation location="/GetWeatherByPlaceName"/>
<wsdl:input>
<http:urlEncoded/>
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="WeatherForecastHttpPost" type="tns:WeatherForecastHttpPost">
<http:binding verb="POST"/>
<wsdl:operation name="GetWeatherByZipCode">
<http:operation location="/GetWeatherByZipCode"/>
<wsdl:input>
<mime:content type="application/x-www-form-urlencoded"/>
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetWeatherByPlaceName">
<http:operation location="/GetWeatherByPlaceName"/>
<wsdl:input>
<mime:content type="application/x-www-form-urlencoded"/>
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WeatherForecast">
<documentation>
Get one week weather forecast for valid zip code or Place name in USA
</documentation>
<wsdl:port name="WeatherForecastSoap" binding="tns:WeatherForecastSoap">
<soap:address location="http://www.webservicex.net/WeatherForecast.asmx"/>
</wsdl:port>
<wsdl:port name="WeatherForecastHttpGet" binding="tns:WeatherForecastHttpGet">
<http:address location="http://www.webservicex.net/WeatherForecast.asmx"/>
</wsdl:port>
<wsdl:port name="WeatherForecastHttpPost" binding="tns:WeatherForecastHttpPost">
<http:address location="http://www.webservicex.net/WeatherForecast.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>