4 Replies Latest reply on Dec 19, 2006 11:46 AM by ntsiii

    Web Service -consuming

    ctsteve Level 1
      Here is an example of a my trying to access a weather web service by entering a zip code. I can't seem to get it to work. Have scoured the web and examples, but no luck. I am using the 30 trial version of flex2 eclipse to evaluate.

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" xmlns="*" >
      <mx:Script>
      <![CDATA[
      import mx.controls.Alert;
      private namespace webservicex=" http://www.webservicex.net/WeatherForecast.asmx?WSDL";
      use namespace webservicex;
      ]]>
      </mx:Script>

      <mx:WebService id="WS" wsdl=" http://www.webservicex.net/WeatherForecast.asmx?WSDL"
      useProxy="false"
      fault="Alert.show(event.fault.faultString), 'Error'"
      result="outputInfo.text = WS.GetWeatherByZipCode.lastResult.toString()" >

      <mx:operation name="GetWeatherByZipCode" resultFormat="e4x" >
      <mx:request>
      <ZipCode>{zipcode.text}</ZipCode>
      </mx:request>
      </mx:operation>
      </mx:WebService>

      <mx:Panel title="WebService Example" height="75%" width="100%"
      paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10" backgroundColor="red" id="myPanel">
      <mx:TextArea x="200" width="900" height="250" backgroundColor="blue" id="outputInfo" />
      <mx:Label width="100%" color="blue"
      text="Enter a zip code."/>

      <mx:TextInput id="zipcode" text=""/>
      <mx:Button label="Get weather" click="WS.GetWeatherByZipCode.send()"/>

      <mx:Text htmlText="place: {WS.GetWeatherByZipCode.lastResult.PlaceName.toString()}"/>
      <mx:Text text="day:{WS.GetWeatherByZipCode.lastResult.Details.WeatherData.Day}" />
      <mx:DataGrid dataProvider="{WS.GetWeatherByZipCode.lastResult.Details.WeatherData}" >
      <mx:columns>
      <mx:DataGridColumn dataField="Day" />
      </mx:columns>
      </mx:DataGrid>

      </mx:Panel>
      </mx:Application>

      Thanks for any feedback. Sure it is simple, but is very frustrating.