简体   繁体   English

WSO2 API Manager 1.9.1-路由

[英]WSO2 API Manager 1.9.1 - Routing

WSO2 API Manger中有什么方法可以从请求xml / json(有效负载)中读取参数值,并基于该值将请求路由到其他后端端点?

You can try using mediator extensions. 您可以尝试使用中介程序扩展。

The API Manager has a default mediation flow for the API invocation requests that it receives. API管理器具有针对其接收的API调用请求的默认中介流。 You can extend this default mediation flow to route the request. 您可以扩展此默认中介流以路由请求。

  1. First write a sequence file to change the flow. 首先编写一个顺序文件以更改流程。 Sample sequence as follows. 采样顺序如下。
 <sequence xmlns="http://ws.apache.org/ns/synapse" name="YahooWeather2"> <property name="YQL" type="Expression" expression="concat('?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22',syn:get-property('uri.var.zipcode'),',',syn:get-property('uri.var.country'),'%22)format=json')"/> <property name="REST_URL_POSTFIX" type="Expression" expression="get-property('YQL')" scope="Axis2"/> </sequence> 
  1. To upload the sequence file to APIM, login as admin go to main-> Resources-> Browse 要将序列文件上传到APIM,请以admin身份登录,转到main-> Resources-> Browse
  2. Go to /_system/governance/apimgt/customsequences/in. 转到/ _system / governance / apimgt / customsequences / in。 from the tree view 从树上看
  3. Click on Add Resource upload the sequence file you created. 单击添加资源,上传您创建的序列文件。
  4. Login to API Publisher ,select the api and click on edit and go to Manage tab. 登录到API Publisher,选择api,然后单击“ 编辑”,然后转到“ 管理”选项卡。
  5. Click on check box for Check to select a custom sequence to be executed in the message flow and in the In Flow dropdown select your sequence( in sample case YahooWeather2 ) and do Save & Publish . 单击Check复选框, 以选择要在消息流中执行的自定义序列,然后在In Flow下拉列表中选择您的序列( 例如 YahooWeather2 )并执行Save&Publish
  6. Login to API store and subscribe the api and generate an access token. 登录到API存储并订阅api并生成访问令牌。

You can check availability from API Console in API store. 您可以从API存储区中的API控制台检查可用性。 for ferther details refer https://docs.wso2.com/display/AM191/Change+the+Default+Mediation+Flow+of+API+Requests 有关更多详细信息,请参阅https://docs.wso2.com/display/AM191/Change+the+Default+Mediation+Flow+of+API+Requests

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

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