This WP7 application takes Zip code as a input from user and calls the Web Service (.ASMX) using HTTP-GET. In this CTP SDK bits we can not add Service Reference to the project so here we are going to use WebClient class to invoke the Web Service and get the Response as XML string then using LINQ TO XML we are going to parse the XML . Here is the look and feel of the WP7 Weather application once we finish building this.
To get weather information by Zip code i am using the following XML Web Service.
http://www.webservicex.net/WeatherForecast.asmx its free.
Steps to Create this application.
- Create New Windows Phone 7 application project
- Build UI using XAML code.
- Get Input from user and call the .ASMX Web service (HTTP-GET)
- Get the Response and Parse it and create UDT ( User Defined Type which stores XML Data).
- Bind UDT to List BOX.
First Create New Windows Phone 7 application .
Here is the XAML code for the above Weather Apps GUI.
Here i am using InputScope property of Text Box to show only numeric keyboard when user enter Zip code in Textbox. Here i am setting Inputsopename NameValue to PostalCode.
Create the UDT ( User Defined Type) class with the following properties to store XML Weather Data as a .NET Type.
In Windows Phone 7 application project right now we can not add Service Reference so we are going to use WebClient class to invoke the web service. This is Siliverlight application so we need to invoke the Web Service method as Asynchronous call .
Once we get the response from Weather WebSerice we are going to use LINQ TO XML to parse the XML data and create the WeatherData UDT type. [ NOTE :We need to add System.Linq.Xml Assembly as reference to our project to parse XML using LINQ]. Once we parse the XML we are setting result to Listbox Itemsource property.
Nandri(Thanks)
SreenivasaRagavan
1 comment:
Very interesting article, I always have had in mind about learning to program applications for cell phones, specially iPhones. Silverlight, .Net and ASP are excellent platforms for software development, these have some similar working effects to the generic viagra in blood circulation.
Post a Comment