2015-02-05 99 views
0

我一直在試驗wso2 API Manager 1.8.0以將後端(http/post)系統公開爲REST API。我能夠使它工作,但我必須通過下面粘貼的服務總線源視圖編輯API配置。我希望爲所有使用API​​ Publisher發佈的新API使用相同的模板,以確保每次創建API時都不必編輯服務總線源。wso2 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:[email protected]'))" 
 
          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:[email protected]'))" 
 
          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> 
 
      \t \t { 
 
      \t \t "apiName": "$1", 
 
      \t \t "apiVersion": "$2", 
 
      \t \t "runResponse": 
 
      \t \t \t { 
 
      \t \t \t \t "runId": "$3", 
 
      \t \t \t \t "runStart": "$4", 
 
      \t \t \t \t "runEnd": "$5", 
 
      \t \t \t \t "flowResponse": "$6", 
 
      \t \t \t \t "flowResult": "$7" 
 
      \t \t \t } 
 
      \t \t }    \t \t \t \t 
 
      \t </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>

回答

0

有似乎是舊版本有關API的模板API管理者的一些文檔下<APIM_HOME>/repository/resources/api-templates/default_api_template.xml文件。

使用API​​ Manager 1.8.0,我無法找到相同的文檔頁面,但編輯velocity_template.xml可用於非原型API定義。

我仍然試圖將我的要求納入其中。

0

其實你想做一些改變你的消息。 APIM 1.8支持調解擴展。您可以在其中添加自己的進出和故障順序,並在那裏進行轉換。此調解擴展支持全球和每api的基礎。你可以在這裏找到細節[1] ,所以如果你創建一個全局級別序列,它將被應用到所有apis。在你的情況下,你必須創建一個全局insequnce來添加基本的oauth相關的東西和一個全局的out序列來添加有效載荷工廠相關東西

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