在端点API WSO2 ESB上动态添加查询参数

时间:2015-06-03 11:16:40

标签: wso2 wso2esb

我正在尝试编辑WSO2 ESB中的api资源,以便在端点URL的末尾显示查询参数。

此时,资源是这样的:

<resource methods="GET" uri-template="/searchEngine/sortAndFilterBeneficiaries*">
  <inSequence>
     <log level="custom">
        <property name="Access token value" expression="$trp:Authorization"/>
     </log>
     <oauthService remoteServiceUrl="https://server:port/services/" username="admin@wso2.com" password="admin"/>
     <header name="Authorization" scope="transport" action="remove"/>
     <send>
        <endpoint>
           <http method="get"
                uri-template="http://server:port/project-web-services/services/project-rs/searchEngine/sortAndFilterBeneficiaries?criterioOrdenacion={query.param.criterioOrdenacion}&amp;registrosPorPagina={query.param.registrosPorPagina}&amp;numPagina={query.param.numPagina}&amp;userId={query.param.userId}&amp;serviciosSeleccionados={query.param.serviciosSeleccionados}&amp;fechaRequerida={query.param.fechaRequerida}&amp;limiteInfDias={query.param.limiteInfDias}&amp;limiteSupDias={query.param.limiteSupDias}&amp;ubicacion={query.param.ubicacion}&amp;limiteDistancia={query.param.limiteDistancia}&amp;valoraciones={query.param.valoraciones}&amp;competencias={query.param.competencias}"/>
        </endpoint>
     </send>
  </inSequence>

但是,我这样做:

<resource methods="GET" url-mapping="/searchEngine/sortAndFilterBeneficiaries*">
  <inSequence>
  <filter source="$ctx:query.param.criterioOrdenacion" regex="PRODUCTION">
<then>
                <property name="REST_URL_POSTFIX" expression="fn:concat(get-property('axis2','REST_URL_POSTFIX'), '&amp;criterioOrdenacion={query.param.type}')" scope="axis2" type="STRING"/>
</then>
  </filter>
     <log level="custom">
        <property name="Access token value" expression="$trp:Authorization"/>
     </log>
     <oauthService remoteServiceUrl="https://server:port/services/" username="admin@wso2.com" password="admin"/>
     <header name="Authorization" scope="transport" action="remove"/>
     <send>
        <endpoint>
           <http method="get"
                uri-template="http://server:port/project-web-services/services/project-rs"/>
        </endpoint>
     </send>
  </inSequence>

这是对的吗?

1 个答案:

答案 0 :(得分:0)

这是对的。如果要更改基本路径,则只会影响一个端点,但在第一种情况下,您必须更新所有动态端点。