wso2 ESB Можно ли удалить параметр URL-адреса перед его отправкой в ​​конечную точку?

Мой прокси получает параметр для принятия решения, который я не хочу отправлять конечной точке, как я могу удалить его перед вызовом конечной точки?

2 ответа

Решение

Для этого вы можете использовать посредник URLRewrite. В библиотеке wso2 есть отличный пример, и вы также можете обратиться к официальной документации wso2.

http://wso2.com/library/3297/

https://docs.wso2.com/display/ESB480/URLRewrite+Mediator

В моем решении я удаляю запрос, когда он равен propName=V1 или propName=V2

<inSequence>
     <property name="sw_prop" expression="$url:propName"
               scope="default" type="STRING"/>

     <property name="querystrings" expression="$axis2:REST_URL_POSTFIX"/>

     <rewrite inProperty="querystrings" outProperty="querystrings">
        <rewriterule>
           <condition>
              <or>
                 <equal type="url" source="query" value="propName=V1"/>
                 <equal type="url" source="query" value="propName=V2"/>
              </or>
           </condition>
           <action type="remove" fragment="query"/>
        </rewriterule>
     </rewrite>

     <property name="REST_URL_POSTFIX"
               expression="get-property('querystrings')"
               scope="axis2"/>

     <switch source="get-property('sw_prop')">
        <case regex="V1">
           <send>
              <endpoint key="EP1"/>
           </send>
        </case>
        <case regex="V2">
           <send>
              <endpoint key="EP2"/>
           </send>
        </case>
        <default>
           <send>
              <endpoint key="AggProxyEP"/>
           </send>
        </default>
     </switch>
</inSequence>
Другие вопросы по тегам