我可以从Windows Mobile应用程序调用REST Web服务吗?

时间:2022-03-09 05:37:25

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?

我想构建一个简单的REST Web服务(使用Ruby on Rails)。但是,我希望能够从Windows移动应用程序调用此服务。那可能吗?或者我必须使用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.

我对Windows Mobile应用程序没有太多经验,所以如果您可以提供伪代码或链接到可能的案例教程,那将是很好的。

Thanks,

Tam

3 个解决方案

#1


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

是的你可以。我使用Win32 wininet API做了很多。

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

您也可以使用System.Net HttpWebRequest API在C#中完成此操作。

#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.

在desctop上,Microsoft提供了一个com接口,可用于实现REST API。也许这也存在于Windows Mobile上。

#3


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

这是使用HttpWebRequest调用twitter搜索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();
        }
    }
}

#1


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

是的你可以。我使用Win32 wininet API做了很多。

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

您也可以使用System.Net HttpWebRequest API在C#中完成此操作。

#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.

在desctop上,Microsoft提供了一个com接口,可用于实现REST API。也许这也存在于Windows Mobile上。

#3


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

这是使用HttpWebRequest调用twitter搜索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();
        }
    }
}