how to use WCF Service in Xamarin.Forms Portable class library

后端 未结 1 1635
醉话见心
醉话见心 2021-01-28 03:39

I am trying to call method created correctly using WCF, I start debugging the project for WCF and the result as the following:

on my xamarin.forms code

相关标签:
1条回答
  • 2021-01-28 04:17

    It seems like you are inspecting the task there, this doesnt give that much information. You can try this little more structured approach.

    using (var httpClient = new HttpClient())
    {
                httpClient.BaseAddress = new Uri("http://localhost:10300");
                var request = "/RestServiceImpl.svc/json";
    
                var result = await httpClient.GetAsync(request);
    
                if (!result.IsSuccessStatusCode)
                    throw new HttpRequestException($"{result.StatusCode} \n {result.Content.ReadAsStringAsync().Result} \n\n {httpClient.BaseAddress}{request}");
    
                var json = await result.Content.ReadAsStringAsync();
    
                Debug.WriteLine(json);
    }
    
    0 讨论(0)
提交回复
热议问题