0

我正在尝试使用 URLrewrite 调解器修改 URL,但它似乎没有效果。

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

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

“/服务/myproxy/user1”

我必须将其重写为:

“/services/myproxy/customer1”(然后到端点:“ 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 请求!

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

谢谢!!!

4

2 回答 2

0

以下语法对我来说是完美的。您正在使用的 ESB 版本是什么?

<rewrite>
         <rewriterule>
            <action value="customer1" regex="user1" type="replace" fragment="path"/>
         </rewriterule>
      </rewrite>
      <send/>
于 2013-09-20T01:40:21.860 回答
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>
于 2021-05-10T06:27:26.173 回答