[英]What is the best way to consume REST services in Windows Store Apps?
I am quite new to Windows Store Apps developement and I need to consume a REST based web service. 我是Windows Store Apps开发的新手,我需要使用基于REST的Web服务。
My issue is that there has been so much movement in development technologies made for consuming modern web services during the last years, that in the end it is hard and confusing to find out what is easiest and, especially, what are the most up to date solutions to achieve that. 我的问题是,在过去的几年中,为使用现代Web服务而开发的开发技术已经发生了如此多的变化,以至于最终很难找出最简单的方法,尤其是最新的方法。解决方案,以实现这一目标。
I want to use the Discogs API in a Windows Store Apps using C#. 我想在Windows商店应用程序中使用C#使用Discogs API 。 I only need to use GET.
我只需要使用GET。
Thanks. 谢谢。
Edit: The main reason why I ask what is the best way to consume REST services in Windows Store Apps, is because I need a solution compliant with asynchrony. 编辑:我问什么是在Windows Store Apps中使用REST服务的最佳方法的主要原因是因为我需要一种与异步兼容的解决方案。
Well of course there's HttpWebRequest
in .NET which is adequate. 当然,.NET中的
HttpWebRequest
就足够了。 If you want some abstraction there are options like RestSharp ( http://restsharp.org/ ). 如果需要抽象,则可以使用诸如RestSharp( http://restsharp.org/ )之类的选项。
Here is a post that contains several library recommendations when consuming REST from .NET 这是一则帖子 ,其中包含从.NET使用REST时的一些库建议。
EDIT: 编辑:
However, unless you are needing something that THIS framework provides...I'd just use the API interface that is already built for you! 但是,除非您需要此框架提供的东西,否则...我只会使用已经为您构建的API接口!
I may as well jump on board with another option: the HttpClient class would be the "out-of-the-box" recommendation in .NET 4.5 (including Windows Store Apps) for your scenario. 我还可以选择使用其他选项: HttpClient类将是针对您的方案的.NET 4.5(包括Windows Store Apps)中的“即用型”建议。 By default, it leverages HttpWebRequest .
默认情况下,它利用HttpWebRequest 。
There's a QuickStart: Connecting using HttpClient on the Dev Center that addresses the GET scenario that should get you pretty far. 有一个快速入门:在开发中心上使用HttpClient进行连接可以解决GET场景,该场景应该可以使您受益匪浅。 And there's a full HttpClient sample as well.
还有完整的HttpClient示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.