在windows phone 8.1中使用restful web服务
热烈的问候。 我想知道如何使用restful web服务(在windows phone 8.1中使用restful web服务,rest,windows-phone-8,Rest,Windows Phone 8,热烈的问候。 我想知道如何使用restful web服务(http://192.168.10.113:8087/cisms/mobilews/),它是在我的windows phone 8.1应用程序中使用java开发的。我正在使用visual studio 2013和c# 更新:我的web服务中的一个GET方法存在另一个问题(http://192.168.10.152:8087/cisms/mobilews/login/userNameCheck?userName=supervisor)。当我基
http://192.168.10.113:8087/cisms/mobilews/
),它是在我的windows phone 8.1应用程序中使用java开发的。我正在使用visual studio 2013和c#
更新:我的web服务中的一个GET方法存在另一个问题(http://192.168.10.152:8087/cisms/mobilews/login/userNameCheck?userName=supervisor
)。当我基于给定的URL创建以下示例代码时,它引发了另一个异常
static string UserValidation()
{
HttpWebRequest req = WebRequest.Create("http://192.168.10.113:8087/cisms/mobilews/login/userNameCheck?userName=supervisor") as HttpWebRequest;
string result = null;
using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse)
{
StreamReader reader =
new StreamReader(resp.GetResponseStream());
result = reader.ReadToEnd();
}
return result;
}
http://rest.elkstein.org/2008/02/using-rest-in-c-sharp.html
例外情况如下
'System.Net.HttpWebRequest' does not contain a definition for 'GetResponse' and no
extension method 'GetResponse' accepting a first argument of type
'System.Net.HttpWebRequest' could be found (are you missing a using directive or an
assembly reference?)
NB:我只在Windows\u Phone\u应用程序中出现此错误;不在桌面应用程序中
如果有人能进一步帮助我,那就太好了
提前谢谢
Sebastian允许您轻松地请求web服务。或者您也可以使用。我已经尝试过httpwebrequest方法,但很少有例外。我正在使用的web服务方法之一是GET;网址如下。。。当我遵循下面的url时;它引发了以下异常“System.Net.HttpWebRequest”不包含“GetResponse”的定义如果您能进一步帮助我,那将是greatI。我不在我的工作电脑前,但也许您可以尝试这样的操作:
HttpWebResponse resp=((wait req.GetResponseAsync())as HttpWebResponse)
我已经尝试过了,但也有同样的例外。我注意到此错误仅出现在windows\u phone\u应用程序中,而不是桌面应用程序中。请尝试使用sy httpClient.GetASync()而不是WebRequest。如果时间允许,您可以给我一个示例,因为我无法将System.Net.Http.dll添加到我的.Net 4.5应用程序中