0
我用下面的代码创建WCF:Xamarin.Forms不能得到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
}
感谢您的提示:) –
确实有帮助您吗? –