在Windows Phone 8.1中使用restful web服务

时间:2014-06-13 11:54:02

标签: rest windows-phone-8

热烈的问候。 我想知道如何使用在我的Windows Phone 8.1应用程序中使用java开发的restful Web服务(http://192.168.10.113:8087/cisms/mobilews/)。我正在使用带有c#的visual studio 2013。

更新:我的网络服务(http://192.168.10.152:8087/cisms/mobilews/login/userNameCheck?userName=supervisor)中有一个GET方法存在其他问题。当我根据给定的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_Phone_application中遇到此错误;不在Desktop_Application中。

如果有人能够进一步帮助我,那就太棒了

提前致谢 塞巴斯蒂安

1 个答案:

答案 0 :(得分:0)

RestSharp可让您轻松请求网络服务。或者您可以使用HttpClient