如何在WSO2 ESB中向API中的URL添加查询参数

如何在WSO2 ESB中向API中的URL添加查询参数,wso2,wso2esb,Wso2,Wso2esb,我需要根据请求中的查询参数将查询参数附加到端点URI 我在ESB中发布了一个资源API,如下所示: <resource methods="GET" url-mapping="/searchEngine/sortAndFilterVolunteers*"> <inSequence> <send> <endpoint> <address uri="http://l

我需要根据请求中的查询参数将查询参数附加到端点URI

我在ESB中发布了一个资源API,如下所示:

<resource methods="GET" url-mapping="/searchEngine/sortAndFilterVolunteers*">
  <inSequence>
     <send>
        <endpoint>
           <address
                uri="http://localhost:8080/project-web-services/services/project-rs"></address>
        </endpoint>
     </send>
  </inSequence>

我必须以友好的方式附加查询参数


我该怎么做呢?

下面的示例API定义可能会对您有所帮助

<api xmlns="http://ws.apache.org/ns/synapse" name="sample" context="/api/sample">
   <resource methods="OPTIONS GET" uri-template="/{val1}/groups/{val2}.json?q1={v1}&q2={v2}">
  <inSequence>
     <property name="uri.var.q1" expression="$url:q1"></property>
     <property name="uri.var.q2" expression="$url:q2"></property>
     <property name="uri.var.val1" expression="get-property('uri.var.val1')"></property>
     <property name="uri.var.val2" expression="get-property('uri.var.val2')"></property>
     <send>
        <endpoint>
           <http method="GET" uri-template=""></http>
        </endpoint>
     </send>
  </inSequence>
  <outSequence>
     <send></send>
  </outSequence>
  </resource>
</api>


将查询参数添加到资源中的uri模板,如下所示:

<resource methods="GET" uri-template="/getStudents/{id}">

发送到端点时

<send>
    <endpoint>
        <http method="get" uri-template="http://studentsapi/student/{uri.var.id}"/>
    </endpoint>
</send>


将查询参数添加到资源中的url映射,如下所示:url映射=“/*”

*
您可以发送一个请求,可能是服务器:端口/服务?q1={q1},而其他请求可能是服务器:端口/服务?q2={q2}&q3={q3}。

我的问题是URL每次都不同。例如,一个请求可以是{q1},其他请求可以是{q2}&q3={q3}。这是因为它们是可选的,需要根据随请求到达的参数进行映射。