title: Consume WCF Rest Service Json data across all platform using Shared Code
body: <p>We were developing a sample MWC application with the logic of Business ,DataAccess,Data Layers.</p>
  
  <p>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...'</p>
  
  <p>We tried to use Async methods for consuming WCF Rest service json data, but it returned as null before the completed method called.</p>
  
  <p>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.</p>
  
  <pre><code>    public String login&lt;T&gt;(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;
      }
  </code></pre>
  
  <p>Edit: I have included the sample code of Async function. </p>
  
  <p>Before Executing the DownloadStringCompleted event it returns null value.  We need that DownloadStringCompleted output string for further process. </p>
  
  <p>Note: We were following the logic of <a href="http://docs.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/case_study-tasky/" rel="nofollow">Tasky in Xamarin </a></p>
  
  <pre><code>    async Task&lt;string&gt; AccessTheWebAsync(string url)
      {
          var webClient = new WebClient();
          webClient.DownloadStringCompleted += (sender, e) =&gt;
          {
              string data =  (string)e.Result;
              check =  data;
          };
          webClient.DownloadStringAsync(new Uri(url));
          return  check;
      }
  
      public async Task&lt;string&gt; login&lt;T&gt;(T item) where T : BusinessLayer.Contracts.IBusinessEntity, new()
      {
          return check = await AccessTheWebAsync(item.url); 
      }
  </code></pre>