简体   繁体   English

在Windows Store Apps中使用REST服务的最佳方法是什么?

[英]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.

相关问题 在Windows应用商店应用中使用Azure表存储的最佳做法是什么? - What is the best practice to consume Azure table storage in a windows store app? 在Silverlight应用程序中存储ADO.NET数据服务URL的最佳位置是什么? - What is the best place to store ADO.NET Data Services URLs in Silverlight apps? Windows Store应用程序(侧载)以及与REST服务的通信 - Windows Store App (sideloaded) and communication with REST services 打印Windows客户端(非Web应用程序)的最佳方式? - Best way to print for Windows Clients (Not Web Apps)? 合并多个Windows Phone应用的最佳方法 - Best way to merge multiple Windows Phone apps Windows Store应用程序中可以使用Microsoft.Phone.Maps.Services吗? - Can Microsoft.Phone.Maps.Services be used in Windows Store Apps? 什么是`收藏的替代品 <T> `,适用于Windows Store应用吗? - What is the alternative to `Collection<T>`, for Windows Store apps? 限制某些用户的服务的最佳方法是什么 - what is the best way to restrict services for certain users 有没有办法检测具有本机C#调用的系统上安装的Windows应用商店应用? - Is there a way to detect what Windows Store apps are installed on a system with native C# calls? 在Silverlight RIA中使用数据库daba的最佳方法是什么 - what is the best way to consume daba of a database in a silverlight RIA
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM