Today we will learn how to connect WCF service with Windows phone.
So let’s start with step by step I am using one of the best templates which Windows Phone 7 support it is data bound template.
We add WCF service project to same solution.
We have created a WCF service which returns Category Id, Category name, Category description from Games database. For this we have created a custom data contract as shown in below fig
Now we added the reference of this service to our windows phone project using add service reference menu which comes when we right click on windows phone project.
Once the service reference is added we won half battle now the next challenge is call the method of this service in our windows phone 7 projects. As you know the first step is to create an object of this service which we can do with following code.
DataServiceFreeTips.CategoryInterfaceClient proxy = new DataServiceFreeTips.CategoryInterfaceClient();
Now all the services which we call using service reference always support asynchronous calling so.
We first create a handler which give us hint when the service get all the data to do this we write following code. And after this service call we call the actual service asynchronous method.
proxy.GetCategoryCompleted += new EventHandler<DataServiceFreeTips.GetCategoryCompletedEventArgs>(proxy_GetCategoryCompleted);
Now we are good to go and now we will run it and see. We will get the entire category game list as shown in below fig.
In this way we can call a WCF service.
For detail you can download the code from
You can download the code at https://skydrive.live.com/?cid=1eda2012469ff8ad&id=1EDA2012469FF8AD!243
Thanks & Best Regards,