wso2 ESB 是否可以在将 url 的参数发送到端点之前将其删除?
wso2 ESB Is it possible to remove a parameter of the url before sending it to the endpoint?
我的代理收到一个参数来做决定,我不想发送端点,如何在调用端点之前删除它?
您可以为此使用 URLRewrite 调解器。 wso2库中有很好的例子,你也可以参考wso2官方文档
在我的解决方案中,我删除了等于 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>
我的代理收到一个参数来做决定,我不想发送端点,如何在调用端点之前删除它?
您可以为此使用 URLRewrite 调解器。 wso2库中有很好的例子,你也可以参考wso2官方文档
在我的解决方案中,我删除了等于 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>