WSO2 APIM 未发布 API 的自定义序列/设置变量

WSO2 APIM Custom sequences for non published APIs / Setting variable

我们已经定义了用于管理不同网关的默认自定义序列,如所述here

我们已经按照 doc Creating Global Conection

中的说明安装了序列

该序列仅从环境中读取 2 个变量,并用于构建端点 URL。这是代码:

<sequence xmlns="http://ws.apache.org/ns/synapse" name="WSO2AM--Ext--In">
        <property name="uri.var.host" expression="get-property('system','host')" />
        <property name="uri.var.port" expression="get-property('system','port')" />
</sequence>

这在 Published API 上运行良好,但如果我们将 API 降级为原型(无需订阅即可直接使用),则无法运行。

我们已经尝试过:

我们测试时的错误报告空主机名(因为它试图读取变量,但它是空的)

你知道如何在原型环境中设置环境变量吗?

当 API 在 "Prototype Endpoint" 中部署时,使用 velocity_template.xml 创建 API 实现。

此模板为 PROTOTYPE 和 PUBLISHED API 生成不同的代码。

我强制包含 APIManagerExtensionHandler(它是处理自定义扩展序列的处理程序),在速度模板中添加以下内容(在处理程序添加循环之后)。

patch --forward $WSO2_PATH//repository/resources/api_templates/velocity_template.xml <<EOF
*** velocity_template.xml   2018-06-02 11:04:42.474476581 +0200
--- velocity_template.xml.patched   2018-06-02 11:07:28.495395384 +0200
***************
*** 361,366 ****
--- 361,369 ----
      #end
  </handler>
  #end
+ #if($apiStatus == 'PROTOTYPED')
+ <handler class="org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler"/>
+ #end
  </handlers>
          #end
          #end
EOF