簡體   English   中英

wso2 API Manager-如何使用模板發布API?

[英]wso2 API Manager - How to publish an API using a template?

我一直在試驗wso2 API Manager 1.8.0,以將后端(http / post)系統公開為REST API。 我能夠使其正常運行,但是我不得不通過Service Bus源代碼視圖編輯API配置,如下所示。 我希望使用與使用API​​ Publisher發布的所有新API相同的模板,以確保我們不必在每次創建API時都編輯服務總線源。

請提出您可能使用過的任何選項。

  <inSequence> <script language="js" key="transform_script" function="buildQueryString"/> <property name="uri.query" expression="get-property('queryString')"/> <filter source="$ctx:AM_KEY_TYPE" regex="PRODUCTION"> <then> <property name="Authorization" expression="fn:concat('Basic ', base64Encode('testuser:testuser@1'))" scope="transport"/> <send> <endpoint name="testuser--AddNumbers_APIsandboxEndpoint_0"> <http method="POST" uri-template="https://testhost:8443/test/http/6731cc67-3850-4b9b-b486-62cf2a664b46?${uri.query}"/> </endpoint> </send> <bam> <serverProfile name="bam-profile"> <streamConfig name="org_wso2_apimgt_statistics_destination" version="1.0.0"/> </serverProfile> </bam> </then> <else> <property name="Authorization" expression="fn:concat('Basic ', base64Encode('testuser:testuser@1'))" scope="transport"/> <send> <endpoint name="testuser--AddNumbers_APIsandboxEndpoint_0"> <http method="POST" uri-template="https://testhost:8443/test/http/6731cc67-3850-4b9b-b486-62cf2a664b46?${uri.query}"/> </endpoint> </send> <bam> <serverProfile name="bam-profile"> <streamConfig name="org_wso2_apimgt_statistics_destination" version="1.0.0"/> </serverProfile> </bam> </else> </filter> </inSequence> <outSequence> <payloadFactory media-type="json"> <format> { "apiName": "$1", "apiVersion": "$2", "runResponse": { "runId": "$3", "runStart": "$4", "runEnd": "$5", "flowResponse": "$6", "flowResult": "$7" } } </format> <args> <arg evaluator="xml" expression="get-property('apiName')"/> <arg evaluator="xml" expression="get-property('apiVersion')"/> <arg evaluator="json" expression="$.runResponse.runReturn.item[0].value"/> <arg evaluator="json" expression="$.runResponse.runReturn.item[3].value"/> <arg evaluator="json" expression="$.runResponse.runReturn.item[4].value"/> <arg evaluator="json" expression="$.runResponse.runReturn.item[5].value"/> <arg evaluator="json" expression="$.runResponse.runReturn.item[6].value"/> </args> </payloadFactory> <property name="messageType" value="application/json" scope="axis2"/> <send/> </outSequence> 

<APIM_HOME>/repository/resources/api-templates/default_api_template.xml文件下,似乎有一些關於API Manager較舊版本的文檔。

使用API​​ Manager 1.8.0時,我找不到相同的文檔頁面,但是編輯Velocity_template.xml可以用於非原型API定義。

我仍在嘗試將我的要求納入其中。

實際上,您想對消息進行一些轉換。 APIM 1.8支持中介擴展。 您可以在其中添加自己的輸入,輸出和故障序列,並在那里進行轉換。 此中介擴展支持全局和每個api。 您可以在此處找到詳細信息[1],因此,如果創建全局級別的序列,它將應用於所有api。在這種情況下,您必須創建一個全局序列以添加基本的oauth相關內容,並創建一個全局out序列以添加有效負載工廠相關的東西

1. https://docs.wso2.com/display/AM180/Adding+Mediation+Extensions

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM