Can I call REST web services from Windows Mobile app

青春壹個敷衍的年華 提交于 2020-01-06 05:25:11

问题


I would like to build a simple REST web service (using Ruby on Rails). However, I would like to be able to call this service from a Windows mobile app. Is that possible? or do I have to use SOAP?

I don't have much experience with Windows Mobile apps so it would be nice if you can provide pseudo code or link to tutorial for the possible case.

Thanks,

Tam


回答1:


Yes you can. I've done it lots using the Win32 wininet API.

You can also do it in C# using the System.Net HttpWebRequest API.




回答2:


 dim sendUrl : sendUrl = baseUrl & url
 dim objXML : Set objXML = CreateObject("MSXML2.ServerXMLHTTP.6.0")

 objXML.open "GET", sendUrl, false

 objXML.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
 objXML.send(sendxml)

 HttpPost = objXml.responseText

 Set objXML = nothing

On desctop Microsoft offers an com interface which can be used to implement REST APIs. Maybe this also exists on Windows Mobile.




回答3:


Here's an example of using a HttpWebRequest to call the twitter search api,hth:

Uri uri = new Uri("http://search.twitter.com/search.json?q=twitter");
String result = String.Empty;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
    using (Stream responseStream = response.GetResponseStream())
    {
        using (StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8))
        {
            result = readStream.ReadToEnd();
        }
    }
}


来源:https://stackoverflow.com/questions/974181/can-i-call-rest-web-services-from-windows-mobile-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!