Accessing the Västtrafik API from Windows Phone 7
[NOTE: The Västtrafik API has changed so this post is obsolete.]
I have been working on a Windows Phone 7 app that would make my commuting to work a bit easier (Västtrafik is not the most reliable commuting service ).
Västtrafik publishes a very neat web service API that is free to use if your are registered in their community (http://labs.vasttrafik.se) and here is some code snippets on how to use it:
public class Class1 { private const string VASTTRAFIK_ID = "..."; private const string STOP_ID = "00012711!-1186562910"; protected Class1() { this.wcfClient = new VasttrafikNextTripService.NextTripSoapClient(); this.wcfClient.GetForecast1Completed += wcfClient_GetForecast1Completed; } public override void UpdateAsync() { this.wcfClient.GetForecast1Async(VASTTRAFIK_ID, STOP_ID); } protected override void EndUpdate() { this.wcfClient.Abort(); } private void wcfClient_GetForecast1Completed(object sender, VasttrafikNextTripService.GetForecast1CompletedEventArgs e) { if (e.Error == null) { var result = ParseXml(e.Result); } else { this.latestVasttrafikTripInfo = null; } this.OnTripInfoUpdated(); } }
Comments are closed.