Can I call REST web services from Windows Mobile a

2019-08-19 01:24发布

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

3条回答
叛逆
2楼-- · 2019-08-19 01:55

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();
        }
    }
}
查看更多
beautiful°
3楼-- · 2019-08-19 02:09

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.

查看更多
beautiful°
4楼-- · 2019-08-19 02:19
 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.

查看更多
登录 后发表回答