简体   繁体   English

创建REST客户端API

[英]Creating a REST client API

I'm currently looking into options for creating a client API for a RESTfull application. 我目前正在研究为RESTfull应用程序创建客户端API的选项。 Up until now we have had WCF services to allow all application to connect to the Business Layer and we're growing dissatisfied with it. 到目前为止,我们已经有了WCF服务,以允许所有应用程序连接到业务层,而我们对此的不满也越来越大。

We already have most of the infrastructure in place for the web (html and json requests) but we need to access the services from other applications (some will be linked against the main web app models library, others won't be). 我们已经拥有大部分用于Web的基础结构(html和json请求),但是我们需要从其他应用程序访问服务(一些将与主要的Web应用程序模型库链接,而其他则不会)。

I've been reading about WADL here and here and it seems like it would be beneficial. 我在这里这里一直在阅读有关WADL的信息 ,看来这将是有益的。 We could generate the wadl, the client libraries and use it to check javascript urls. 我们可以生成wadl,客户端库并将其用于检查javascript网址。

I would like to know what others have used, what worked and what didn't. 我想知道其他人使用了什么,什么有用,什么没用。

A good rest client API is a set of wrappers around curl, wget, or your language specific HTTP libraries. 一个好的客户端API是围绕curl,wget或您的语言特定的HTTP库的一组包装。 You might need some extra methods or functions to deal with the specifics of your application as well (ie specialized XML/JSON parsing), but that should be about it. 您可能还需要一些额外的方法或函数来处理应用程序的细节(即,专门的XML / JSON解析),但这应该是有关的。

In the REST architecture: 在REST体系结构中:

  • The resources link to their description documents, if they have one, not the other way around. 资源链接到其描述文档(如果有的话),而不是相反的链接。
  • The resources are not complex (not RPC like), thus there is usually no need for a description document. 资源并不复杂(不像RPC一样),因此通常不需要描述文件。
  • Loose Coupling is king; 联轴器为王; contracts are both unnecessary and harmful. 合同既不必要又有害。
  • Resources link to each others, removing most of the need for resource discovery services. 资源彼此链接,从而消除了对资源发现服务的大部分需求。

iBeans is a new open source project that is attempting to provide a solution to this. iBeans是一个新的开源项目,正在尝试为此提供解决方案。 iBeans (Integration Beans) are client APIs for RESTful or other services. iBean(集成Bean)是用于RESTful或其他服务的客户端API。 Currently iBeans does require a server (you can drop the framework into Tomcat quite easily) and can be used from Javascript or java applications. 当前,iBeans确实需要服务器(您可以很容易地将框架放入Tomcat),并且可以在Javascript或Java应用程序中使用。

Try this web app: FRAPI . 尝试以下Web应用程序: FRAPI It's quite impressive 令人印象深刻

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM