[英]How to publish an existing API on WSO2 ESB
I can't seem to find a simple article on how to publish an existing restAPI through WSO2 ESB as proxy. 我似乎找不到关于如何通过WSO2 ESB作为代理发布现有restAPI的简单文章。
I have an existing API which responds with either Json or XML output based on content-type on the header. 我有一个现有的API,它根据标头上的内容类型用Json或XML输出进行响应。 I would like to publish this api through the WSO2 ESB as proxy. 我想通过WSO2 ESB作为代理发布此api。 I don't think WSO2 Application server is needed in this case, as the rest api is running on its own app server. 我认为在这种情况下不需要WSO2应用服务器,因为其余api在其自己的应用服务器上运行。
API: http://somehost.com:8001/api/BusinessApi/GetContentTypes API: http : //somehost.com : 8001/ api/ BusinessApi/GetContentTypes
Response: 响应:
[{"contentTypeID":1,"name":"Movies","isTop":true,"subLevels":1,"contentTypeIdBase":1},{"contentTypeID":2,"name":"TV Show","isTop":true,"subLevels":3,"contentTypeIdBase":4},{"contentTypeID":3,"name":"TV Season","isTop":false,"subLevels":2,"contentTypeIdBase":4},{"contentTypeID":4,"name":"TV Episode","isTop":false,"subLevels":1,"contentTypeIdBase":4},{"contentTypeID":5,"name":"Music Album","isTop":true,"subLevels":2,"contentTypeIdBase":6},{"contentTypeID":6,"name":"Music Track","isTop":false,"subLevels":1,"contentTypeIdBase":6},{"contentTypeID":7,"name":"Music Video","isTop":false,"subLevels":1,"contentTypeIdBase":7},{"contentTypeID":8,"name":"Book Set","isTop":false,"subLevels":1,"contentTypeIdBase":8},{"contentTypeID":9,"name":"Books","isTop":true,"subLevels":1,"contentTypeIdBase":9}]
The objective is to publish the api via WSO2 ESB and try to achieve the below actions: 目的是通过WSO2 ESB发布api,并尝试实现以下操作:
Thanks in Advance!! 提前致谢!!
Setting up a proxy API, this can only be done via 设置代理API,只能通过以下方式完成
Begin of snippet 摘要的开头
<api xmlns="http://ws.apache.org/ns/synapse" name="GetC" context="/api1">
<resource methods="GET" url-mapping="/">
<inSequence>
<log/>
<send>
<endpoint>
<address uri="http://somehost.com:8001/api/businessApi/GetContentTypes"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log/>
<send/>
</outSequence>
</resource>
</api>
End of snippet 摘要结束
You should now be to access the api via ESB proxy url 您现在应该通过ESB代理URL访问api
With your approach, you have created an api in ESB, which passes the request to your backend api. 使用您的方法,您已经在ESB中创建了一个api,它将请求传递给您的后端api。 During this you expect to log every api call and control authentication too. 在此期间,您还希望记录每个api调用并控制身份验证。 I didn't understand the forking requirement. 我不了解分叉的要求。
Have you tried WSO2 API Manager ? 您是否尝试过WSO2 API管理器 ? It will allow you to make your api a managed api. 它将使您可以将api设为托管api。 ie You will be able to control access to your api via oauth tokens. 即,您将能够通过oauth令牌控制对api的访问。 You can log the api calls too (although its not a good thing to log every call due to performance reasons). 您也可以记录api调用(尽管由于性能原因,记录每个调用不是一件好事)。
If you integrate it with WSO2 DAS, you will be able to see some useful stats too. 如果将其与WSO2 DAS集成,您还将能够看到一些有用的统计信息。 This is the API Manager documentation. 这是API Manager文档。
https://docs.wso2.com/display/AM1100/WSO2+API+Manager+Documentation https://docs.wso2.com/display/AM1100/WSO2+API+Manager+Documentation
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.