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
}
感謝您的提示:) –
確實有幫助您嗎? –