web service

  • Thread starter Thread starter Brock
  • Start date Start date
B

Brock

I have a classic textbook example of consuming a Web service. I'm
using Visual Web Developer Express 2008 v9. I have a textbox, a
listbox, and a button on my .aspx form. I'm trying to use the
http://developer.capeclear.com/files/GlobalWeather.wsdl as my Web
reference which looks good so far. But my code has some what will
assurably be obvious flaws to many. You can see the WSDL at the above
link. The method in that I am trying to use is "searchByCode"... so I
would of course enter an airport code like "LAX" and get weather for
Los Angeles. The following code needs some help. the compiler doesn't
like the item "textCode" below and it's saying that all the "ws." 's
are not declared. Anyone? THANKS!!

<script runat="server">

Private Sub btnGetSummary_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnGetSummary.Click
Dim aw As com.capeclear.developer.WeatherReport = New
com.capeclear.developer.WeatherReport()
Dim ws As
com.capeclear.developer.getWeatherReport(txtCode.Text)
With lbResults.Items
.Clear()
.Add("Visibility: " & ws.visibility)
.Add("Temperature: " & ws.temperature)
.Add("Winds: " & ws.winds)
.Add("Precipitation: " & ws.precipitation)
.Add("Sky: " & ws.sky)
.Add("Pressure: " & ws.pressure)
End With
End Sub

</script>
 
I have a classic textbook example of consuming a Web service. I'm
using Visual Web Developer Express 2008 v9. I have a textbox, a
listbox, and a button on my .aspx form. I'm trying to use thehttp://developer.capeclear.com/files/GlobalWeather.wsdlas my Web
reference which looks good so far. But my code has some what will
assurably be obvious flaws to many. You can see the WSDL at the above
link. The method in that I am trying to use is "searchByCode"... so I
would of course enter an airport code like "LAX" and get weather for
Los Angeles. The following code needs some help. the compiler doesn't
like the item "textCode" below and it's saying that all the "ws." 's
are not declared. Anyone? THANKS!!

<script runat="server">

    Private Sub btnGetSummary_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnGetSummary.Click
        Dim aw As com.capeclear.developer.WeatherReport = New
com.capeclear.developer.WeatherReport()
        Dim ws As
com.capeclear.developer.getWeatherReport(txtCode.Text)
        With lbResults.Items
            .Clear()
            .Add("Visibility: " & ws.visibility)
            .Add("Temperature: " & ws.temperature)
            .Add("Winds: " & ws.winds)
            .Add("Precipitation: " & ws.precipitation)
            .Add("Sky: " & ws.sky)
            .Add("Pressure: " & ws.pressure)
        End With
    End Sub

</script>

It look to me like you have "Dim ws As <a method invocation>" where
what you want, I think, is "Dim ws As <a type> = <a method
invocation>"

In other words, what is the object type returned by
com.capeclear.developer.getWeatherReport(txtCode.Text) ? you need ws
declared to be that type before you can invoke the getWeatherReport()
method.
 
I checked through the WSDL below but I'm not following what I should
do.
Something like this?: Dim ws As String() =
<someMethod>(txtCode.Text)

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://
www.capeclear.com/globalweather/wsdl/" xmlns:xsd="http://www.w3.org/
2001/XMLSchema" xmlns:xsd1="http://www.capeclear.com/globalweather/
xsd/" xmlns="http://schemas.xmlsoap.org/wsdl/" name="GlobalWeather"
targetNamespace="http://www.capeclear.com/globalweather/wsdl/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema attributeFormDefault="unqualified"
elementFormDefault="qualified" targetNamespace="http://
www.capeclear.com/globalweather/xsd/">
<xsd:element name="getStation">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="code" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getStationResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="return" type="xsd1:Station" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getWeatherReport">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="code" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getWeatherReportResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="return" type="xsd1:WeatherReport" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="isValidCode">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="code" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="isValidCodeResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="return" type="xsd:boolean" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="listCountries">
<xsd:complexType>
<xsd:sequence />
</xsd:complexType>
</xsd:element>
<xsd:element name="listCountriesResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="return" type="xsd1:ArrayOfstring" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="searchByCode">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="code" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="searchByCodeResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="return" type="xsd1:ArrayOfStation" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="searchByCountry">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="country" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="searchByCountryResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="return" type="xsd1:ArrayOfStation" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="searchByLocation">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="latitude" type="xsd1:Range" />
<xsd:element name="longitude" type="xsd1:Range" />
<xsd:element name="elevation" type="xsd1:Range" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="searchByLocationResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="return" type="xsd1:ArrayOfStation" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="searchByName">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="searchByNameResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="return" type="xsd1:ArrayOfStation" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="searchByRegion">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="region" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="searchByRegionResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="return" type="xsd1:ArrayOfStation" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="ArrayOfExtreme">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded"
name="extreme" type="xsd1:Extreme" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="PhenomenonIntensity">
<xsd:complexContent mixed="false">
<xsd:extension base="xsd1:Enum">
<xsd:sequence />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="Direction">
<xsd:sequence>
<xsd:element minOccurs="0" name="compass"
type="xsd1:DirectionCompass" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Sky">
<xsd:sequence>
<xsd:element name="ceiling_altitude" type="xsd:double" />
<xsd:element minOccurs="0" name="layers"
type="xsd1:ArrayOfLayer" />
<xsd:element minOccurs="0" name="string" type="xsd:string" /</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Station">
<xsd:sequence>
<xsd:element minOccurs="0" name="icao" type="xsd:string" />
<xsd:element minOccurs="0" name="wmo" type="xsd:string" />
<xsd:element minOccurs="0" name="iata" type="xsd:string" />
<xsd:element name="elevation" type="xsd:double" />
<xsd:element name="latitude" type="xsd:double" />
<xsd:element name="longitude" type="xsd:double" />
<xsd:element minOccurs="0" name="country" type="xsd:string"/<xsd:element minOccurs="0" name="string" type="xsd:string" /</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Enum" abstract="true">
<xsd:sequence>
<xsd:element minOccurs="0" name="value" type="xsd:string" />
<xsd:element name="hashCode" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="WeatherReport">
<xsd:sequence>
<xsd:element minOccurs="0" name="timestamp"
type="xsd:dateTime" />
<xsd:element minOccurs="0" name="station"
type="xsd1:Station" />
<xsd:element minOccurs="0" name="phenomena"
type="xsd1:ArrayOfPhenomenon" />
<xsd:element minOccurs="0" name="precipitation"
type="xsd1:ArrayOfPrecipitation" />
<xsd:element minOccurs="0" name="extremes"
type="xsd1:ArrayOfExtreme" />
<xsd:element minOccurs="0" name="pressure"
type="xsd1:Pressure" />
<xsd:element minOccurs="0" name="sky" type="xsd1:Sky" />
<xsd:element minOccurs="0" name="temperature"
type="xsd1:Temperature" />
<xsd:element minOccurs="0" name="visibility"
type="xsd1:Visibility" />
<xsd:element minOccurs="0" name="wind" type="xsd1:Wind" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="DirectionCompass">
<xsd:complexContent mixed="false">
<xsd:extension base="xsd1:Enum">
<xsd:sequence />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="Pressure">
<xsd:sequence>
<xsd:element name="altimeter" type="xsd:double" />
<xsd:element name="slp" type="xsd:double" />
<xsd:element name="delta" type="xsd:double" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ExtremeType">
<xsd:complexContent mixed="false">
<xsd:extension base="xsd1:Enum">
<xsd:sequence />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="Wind">
<xsd:sequence>
<xsd:element name="prevailing_speed" type="xsd:double" />
<xsd:element name="gust_speed" type="xsd:double" />
<xsd:element minOccurs="0" name="prevailing_direction"
type="xsd1:Direction" />
<xsd:element minOccurs="0" name="varying_from_direction"
type="xsd1:Direction" />
<xsd:element minOccurs="0" name="varying_to_direction"
type="xsd1:Direction" />
<xsd:element minOccurs="0" name="string" type="xsd:string" /</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="PhenomenonType">
<xsd:complexContent mixed="false">
<xsd:extension base="xsd1:Enum">
<xsd:sequence />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="Range">
<xsd:sequence>
<xsd:element name="from" type="xsd:double" />
<xsd:element name="to" type="xsd:double" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ArrayOfPrecipitation">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded"
name="precipitation" type="xsd1:Precipitation" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Temperature">
<xsd:sequence>
<xsd:element name="ambient" type="xsd:double" />
<xsd:element name="dewpoint" type="xsd:double" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Phenomenon">
<xsd:sequence>
<xsd:element minOccurs="0" name="type"
type="xsd1:PhenomenonType" />
<xsd:element minOccurs="0" name="intensity"
type="xsd1:PhenomenonIntensity" />
<xsd:element minOccurs="0" name="string" type="xsd:string" /</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Precipitation">
<xsd:sequence>
<xsd:element name="amount" type="xsd:double" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ArrayOfPhenomenon">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded"
name="phenomenon" type="xsd1:Phenomenon" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Layer">
<xsd:sequence>
<xsd:element name="altitude" type="xsd:double" />
<xsd:element name="extent" type="xsd:int" />
<xsd:element minOccurs="0" name="type"
type="xsd1:PhenomenonType" />
<xsd:element minOccurs="0" name="string" type="xsd:string" /</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Extreme">
<xsd:sequence>
<xsd:element minOccurs="0" name="temperature"
type="xsd1:Temperature" />
<xsd:element minOccurs="0" name="type"
type="xsd1:ExtremeType" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ArrayOfLayer">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded"
name="layer" type="xsd1:Layer" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ArrayOfstring">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="item"
type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ArrayOfStation">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded"
name="station" type="xsd1:Station" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Visibility">
<xsd:sequence>
<xsd:element name="distance" type="xsd:double" />
<xsd:element minOccurs="0" name="qualifier"
type="xsd1:VisibilityQualifier" />
<xsd:element minOccurs="0" name="string" type="xsd:string" /</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="VisibilityQualifier">
<xsd:complexContent mixed="false">
<xsd:extension base="xsd1:Enum">
<xsd:sequence />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="getWeatherReport">
<wsdl:part name="getWeatherReport"
element="xsd1:getWeatherReport" />
</wsdl:message>
<wsdl:message name="getStationResponse">
<wsdl:part name="getStationResponse"
element="xsd1:getStationResponse" />
</wsdl:message>
<wsdl:message name="listCountries">
<wsdl:part name="listCountries" element="xsd1:listCountries" />
</wsdl:message>
<wsdl:message name="getStation">
<wsdl:part name="getStation" element="xsd1:getStation" />
</wsdl:message>
<wsdl:message name="isValidCodeResponse">
<wsdl:part name="isValidCodeResponse"
element="xsd1:isValidCodeResponse" />
</wsdl:message>
<wsdl:message name="isValidCode">
<wsdl:part name="isValidCode" element="xsd1:isValidCode" />
</wsdl:message>
<wsdl:message name="searchByNameResponse">
<wsdl:part name="searchByNameResponse"
element="xsd1:searchByNameResponse" />
</wsdl:message>
<wsdl:message name="searchByCountryResponse">
<wsdl:part name="searchByCountryResponse"
element="xsd1:searchByCountryResponse" />
</wsdl:message>
</wsdl:message>
<wsdl:message name="searchByName">
<wsdl:part name="searchByName" element="xsd1:searchByName" />
</wsdl:message>
<wsdl:message name="searchByLocation">
<wsdl:part name="searchByLocation"
element="xsd1:searchByLocation" />
</wsdl:message>
<wsdl:message name="searchByRegion">
<wsdl:part name="searchByRegion" element="xsd1:searchByRegion" />
</wsdl:message>
<wsdl:message name="searchByCodeResponse">
<wsdl:part name="searchByCodeResponse"
element="xsd1:searchByCodeResponse" />
</wsdl:message>
<wsdl:message name="searchByRegionResponse">
<wsdl:part name="searchByRegionResponse"
element="xsd1:searchByRegionResponse" />
</wsdl:message>
<wsdl:message name="searchByLocationResponse">
<wsdl:part name="searchByLocationResponse"
element="xsd1:searchByLocationResponse" />
</wsdl:message>
<wsdl:message name="searchByCode">
<wsdl:part name="searchByCode" element="xsd1:searchByCode" />
</wsdl:message>
<wsdl:message name="getWeatherReportResponse">
<wsdl:part name="getWeatherReportResponse"
element="xsd1:getWeatherReportResponse" />
</wsdl:message>
<wsdl:message name="listCountriesResponse">
<wsdl:part name="listCountriesResponse"
element="xsd1:listCountriesResponse" />
</wsdl:message>
<wsdl:portType name="StationInfo">
<wsdl:operation name="getStation">
<wsdl:input message="tns:getStation" />
<wsdl:output message="tns:getStationResponse" />
</wsdl:operation>
<wsdl:operation name="isValidCode">
<wsdl:input message="tns:isValidCode" />
<wsdl:output message="tns:isValidCodeResponse" />
</wsdl:operation>
<wsdl:operation name="listCountries">
<wsdl:input message="tns:listCountries" />
<wsdl:output message="tns:listCountriesResponse" />
</wsdl:operation>
<wsdl:operation name="searchByCode">
<wsdl:input message="tns:searchByCode" />
<wsdl:output message="tns:searchByCodeResponse" />
</wsdl:operation>
<wsdl:operation name="searchByCountry">
<wsdl:input message="tns:searchByCountry" />
<wsdl:output message="tns:searchByCountryResponse" />
</wsdl:operation>
<wsdl:operation name="searchByLocation">
<wsdl:input message="tns:searchByLocation" />
<wsdl:output message="tns:searchByLocationResponse" />
</wsdl:operation>
<wsdl:operation name="searchByName">
<wsdl:input message="tns:searchByName" />
<wsdl:output message="tns:searchByNameResponse" />
</wsdl:operation>
<wsdl:operation name="searchByRegion">
<wsdl:input message="tns:searchByRegion" />
<wsdl:output message="tns:searchByRegionResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="GlobalWeather">
<wsdl:operation name="getWeatherReport">
<wsdl:input message="tns:getWeatherReport" />
<wsdl:output message="tns:getWeatherReportResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="StationInfoBinding" type="tns:StationInfo">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getStation">
<soap:operation soapAction="" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="isValidCode">
<soap:operation soapAction="" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="listCountries">
<soap:operation soapAction="" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="searchByCode">
<soap:operation soapAction="" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="searchByCountry">
<soap:operation soapAction="" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="searchByLocation">
<soap:operation soapAction="" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="searchByName">
<soap:operation soapAction="" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="searchByRegion">
<soap:operation soapAction="" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="GlobalWeatherBinding" type="tns:GlobalWeather">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getWeatherReport">
<soap:operation soapAction="" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="GlobalWeather">
<wsdl:port name="GlobalWeather"
binding="tns:GlobalWeatherBinding">
<soap:address location="http://live.capeclear.com/ccx/
GlobalWeather" />
</wsdl:port>
<wsdl:port name="StationInfo" binding="tns:StationInfoBinding">
<soap:address location="http://live.capeclear.com/ccx/
GlobalWeather" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
 
Back
Top