我试图创建一个自定义策略,目的是一个服务的掩码:
API中的原始服务:
http://API/v1/profile
http://API/v1/account带面具:
http://API/v1/user-profile
http://API/v1/user-account并结合用户Bee的答案这是一个解决这个问题的解决方案:
<switch source="get-property('axis2', 'REST_URL_POSTFIX')">
<case regex="/v1/kyc-profile">
<property name="REST_URL_POSTFIX" value="/v1/profile" scope="axis2"/>
</case>
<case regex="/v1/kyc-account">
<property name="REST_URL_POSTFIX" value="/v1/account" scope="axis2"/>
</case>
</switch>但是这个解决方案只在服务是静态的情况下工作,但是我有其他服务,类似于:
http://API/v1/user-profile/{id-user}/details
http://API/v1/user-profile/{id-user}?expand=some_information在最后一项服务中,我有以下内容:
<switch source="get-property('axis2', 'REST_URL_POSTFIX')">
<case regex="v1/user-profile/[\/\w\W]*">
<property name="REST_URL_POSTFIX" value="/v2/cliente/{id-user}?expand=some_information" scope="axis2"/>
</case>
</switch>这个部分是{id-user}?expand=some_information和类似的正则表达式。
问题是:我需要放置value="THIS"动态值,因为property value (<property name="REST_URL_POSTFIX" scope="axis2"/>)以本文为例:
在送达前送达政策
http://API/v1/user-profile/1?expand=some_information送达后送达政策
http://API/v1/user-profile/{id-user}?expand=some_information我的问题是:
http://API/v1/user-profile/{id-user}?expand=some_information
http://API/v1/user-profile/{id-user}/details我有相似的情况,如何解决?发布于 2020-02-18 02:35:52
在中介序列中,尝试更改后端URL,如下所示。
http://API/v1/user-profile/{uri.var.id-user}?expand=some_information示例:
<switch source="get-property('axis2', 'REST_URL_POSTFIX')">
<case regex="v1/user-profile/[\/\w\W]*">
<property name="REST_URL_POSTFIX" value="/v2/cliente/{uri.var.id-user}?expand=some_information" scope="axis2"/>
</case>
</switch>https://stackoverflow.com/questions/60271939
复制相似问题