Consume WCF Rest Service Json data across all platform using Shared Code

Hi friends,

We were developing a sample MWC application with the logic of Business ,DataAccess,Data Layers.

In core Project we used the following code for consuming data from json parsing. This code works fine for Xamarin.Android and Xamarin.iOS, but for windows phone it shows error as 'System.Net.WebRequest does not contain a definition for GetResponse and no extension method for GetResponse...'

We tried to use Async methods for consuming WCF Rest service json data, but it returned as null before the completed method called.

Is it possible to wait and get data from completed method to return the json collection? if no please suggest how to achieve the same.

public String login<T>(T item) where T : BusinessLayer.Contracts.IBusinessEntity, new() { var request = HttpWebRequest.Create(url); request.ContentType = "application/json"; request.Method = "get"; using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { using (StreamReader reader = new StreamReader(response.GetResponseStream())) { var content = reader.ReadToEnd(); string nss = content.ToString(); check = nss; return nss; } } return Check; }

Sign In or Register to comment.