WSO2 ESB URL重写没有效果?

时间:2013-09-19 14:17:05

标签: url-rewriting wso2 wso2esb

我正在尝试使用URLrewrite介体修改URL,但似乎没有效果。

我想将“user1”替换为“customer1”,然后将请求发送到端点

在我的代理中,我收到了这个网址:

“/服务/ MYPROXY / USER1”

我必须将其重写为:

“/ services / myproxy / customer1”(然后是endpont:“http://endpoint.com/customer1”)。

URLRewrite介体是:

<rewrite xmlns="http://ws.apache.org/ns/synapse">
   <rewriterule>
      <action value="customer1" regex="user1" type="replace" fragment="path"/>
   </rewriterule>
</rewrite>

但最后代理使用“user1”而不是“customer1”发送URL请求!!

我的配置有什么问题?我的日志中没有看到任何错误!!

感谢!!!

2 个答案:

答案 0 :(得分:0)

以下语法对我来说非常合适。您正在使用的ESB版本是什么?

<rewrite>
         <rewriterule>
            <action value="customer1" regex="user1" type="replace" fragment="path"/>
         </rewriterule>
      </rewrite>
      <send/>

答案 1 :(得分:0)

我遇到了类似的问题。就我而言,我错过了在重写 url 后将 outProperty 重新设置为 REST_URL_POSTFIX。希望这可以帮助将来遇到同样问题的人。

<sequence>
  <property name="REST_URL_POSTFIX" expression="get-property('axis2','REST_URL_POSTFIX')"/>
  <rewrite inProperty="REST_URL_POSTFIX" outProperty="REST_URL_POSTFIX">
    <rewriterule>
      <action fragment="path" type="replace" regex="^/soap/sms" value="/sms" />
    </rewriterule>
  </rewrite>
  
  <property name="REST_URL_POSTFIX" scope="axis2" expression="get-property('REST_URL_POSTFIX')"/>
  ^^ Make sure to set this back ^^
</sequence>