如何修改WSO2 APIM处理程序的序列

如何修改WSO2 APIM处理程序的序列,wso2,wso2-am,Wso2,Wso2 Am,我将WSO2 APIM 1.10.0与我的自定义处理程序一起使用,这些处理程序被引用 我有两个全局自定义处理程序: 海德斯瓦芬德勒 ApiInformHandler 我希望在创建API时,这两个自定义处理程序的顺序如下所示 <handlers> <handler class="com.wso2.header.handler.HeaderSwapHandler"/> <handler class="org.wso2.carbon.apimgt.gateway.

我将WSO2 APIM 1.10.0与我的自定义处理程序一起使用,这些处理程序被引用

我有两个全局自定义处理程序:

  • 海德斯瓦芬德勒
  • ApiInformHandler
  • 我希望在创建API时,这两个自定义处理程序的顺序如下所示

    <handlers>
      <handler class="com.wso2.header.handler.HeaderSwapHandler"/>
      <handler class="org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler">
         <property name="apiImplementationType" value="ENDPOINT"/>
      </handler>
      <handler class="org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler"/>
      <handler class="org.wso2.carbon.apimgt.gateway.handlers.throttling.APIThrottleHandler">
         <property name="policyKey" value="gov:/apimgt/applicationdata/tiers.xml"/>
         <property name="policyKeyApplication"
                   value="gov:/apimgt/applicationdata/app-tiers.xml"/>
         <property name="id" value="A"/>
         <property name="policyKeyResource"
                   value="gov:/apimgt/applicationdata/res-tiers.xml"/>
      </handler>
      <handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageHandler"/>
      <handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtGoogleAnalyticsTrackingHandler">
         <property name="configKey" value="gov:/apimgt/statistics/ga-config.xml"/>
      </handler>
      <handler class="org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler"/>
      <handler class="com.wso2.header.handler.APIInforHandler"/>
    </handlers>
    
    只需更改为:

    <handlers xmlns="http://ws.apache.org/ns/synapse">
    <handler class="com.wso2.header.handler.HeaderSwapHandler"/>
    #foreach($handler in $handlers)
    <handler xmlns="http://ws.apache.org/ns/synapse" class="$handler.className">
        #if($handler.hasProperties())
        #set ($map = $handler.getProperties() )
        #foreach($property in $map.entrySet())
        <property name="$!property.key" value="$!property.value"/>
        #end
        #end
    </handler>
    #end
    <handler class="com.wso2.header.handler.APIInforHandler"/>
    </handlers>
            #end
            #end
            #if($apiStatus == 'PROTOTYPED')
            #end
            ## end of apiIsBlocked check
             <handlers>
          <handler class="org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler">
             <property name="inline" value="INLINE"/>
          </handler>
           </handlers>
            </api>
    
    
    #foreach($handlers中的$handlers)
    #if($handler.hasProperties())
    #set($map=$handler.getProperties())
    #foreach($map.entrySet()中的属性)
    #结束
    #结束
    #结束
    #结束
    #结束
    #如果($apiStatus=='PROTOTYPED')
    #结束
    ##APIsBlocked检查结束
    

    这可以解决我的问题。

    在您所指的同一页中,它有
    使用自定义处理程序部分。它显示了如何使用
    velocity\u template.xml
    将新处理程序加入API。

    在您所指的同一页面中,它有
    加入自定义处理程序部分。它展示了如何使用
    velocity\u template.xml
    让您的新处理程序加入API。

    谢谢@Bhathiya,只要编辑
    velocity\u template.xml
    文件就可以解决我的问题。谢谢@Bhathiya,只要编辑
    velocity\u template.xml
    文件就可以解决我的问题。
    <handlers xmlns="http://ws.apache.org/ns/synapse">
    <handler class="com.wso2.header.handler.HeaderSwapHandler"/>
    #foreach($handler in $handlers)
    <handler xmlns="http://ws.apache.org/ns/synapse" class="$handler.className">
        #if($handler.hasProperties())
        #set ($map = $handler.getProperties() )
        #foreach($property in $map.entrySet())
        <property name="$!property.key" value="$!property.value"/>
        #end
        #end
    </handler>
    #end
    <handler class="com.wso2.header.handler.APIInforHandler"/>
    </handlers>
            #end
            #end
            #if($apiStatus == 'PROTOTYPED')
            #end
            ## end of apiIsBlocked check
             <handlers>
          <handler class="org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler">
             <property name="inline" value="INLINE"/>
          </handler>
           </handlers>
            </api>