【发布时间】:2017-01-23 12:52:22
【问题描述】:
我使用以下代码创建了一个 wcf:
[ServiceContract]
public interface IRestServiceImpl
{
[OperationContract]
[WebGet( ResponseFormat = WebMessageFormat.Json,
BodyStyle =WebMessageBodyStyle.Wrapped,
UriTemplate = "json")]
string JSONData();
}
public class RestServiceImpl : IRestServiceImpl
{
public string JSONData()
{
return "You Requested Prodcut";
}
}
当我试图从 xamarin.forms 应用程序中获取价值时,我得到一个异常
System.Net.WebExceptionStatus.ConnectFailure
,结果应该是什么?
private async Task DownloadInfo()
{
var Uri = "http://localhost:8020/wcfrest/RestServiceImpl.svc/json";
var httpClient = new HttpClient();
var json= await httpClient.GetStringAsync(Uri);//I get exception here System.Net.WebExceptionStatus.ConnectFailure
}
【问题讨论】:
标签: c# xamarin.forms portable-class-library