2
votes

I would like to create a Dynamic HTTP Endpoint in WSO2. I have a sequence (Tconf) which contains all the property values. I am deriving them, using the Property Mediator. Once I get the variables, I am using the SendMediator to send an rest request. Unfortunately it does not seem to be working. Not sure what I am doing wrong, but none of the properties are getting appended. I can see all the properties when I log them.

<api xmlns="http://ws.apache.org/ns/synapse" name="TririgaApi" context="/tririga">
   <resource methods="GET" url-mapping="/employee">
      <inSequence>
         <sequence key="Tconf"/>
         <property xmlns:ns="http://org.apache.synapse/xsd" name="uri.var.service.user" expression="get-property('tri.service.user')"/>
         <property xmlns:ns="http://org.apache.synapse/xsd" name="uri.var.service.pass" expression="get-property('tri.service.pass')"/>
         <property xmlns:ns="http://org.apache.synapse/xsd" name="uri.var.service.host" expression="get-property('tri.service.host')"/>
         <property xmlns:ns="http://org.apache.synapse/xsd" name="uri.var.service.path" expression="get-property('tri.service.path')"/>
         <property xmlns:ns="http://org.apache.synapse/xsd" name="uri.var.service.wfName" expression="get-property('triPeople.database.employee.wfName')"/>
         <send>
            <endpoint>
               <http method="GET" uri-template="http://host:port/{uri.service.host}{uri.var.service.path}?USERNAME={uri.var.service.user}&amp;PASSWORD={uri.var.service.pass}&amp;ioName={uri.var.service.wfName}"/>
            </endpoint>
         </send>
      </inSequence>
   </resource>
</api>
1
First check if the values are properly set to the properties using a log mediator. If the values are correctly set then this should workThusitha Thilina Dayaratne

1 Answers

1
votes

You can configure your sequence and API like below to acheive your requirnment.

Sequence Config:

<sequence xmlns="http://ws.apache.org/ns/synapse">
    <property name="uri.var.service.user" scope="default" type="STRING" value="testuser"/>
    <property name="uri.var.service.pass" scope="default" type="STRING" value="testpasswd"/>
    <property name="uri.var.service.host" scope="default" type="STRING" value="testhost"/>
    <property name="uri.var.service.path" scope="default" type="STRING" value="testpath"/>
    <property name="uri.var.service.wfName" scope="default"
        type="STRING" value="testwfName"/>
</sequence>

API Config:

<api xmlns="http://ws.apache.org/ns/synapse" name="TririgaApi" context="/tririga">
   <resource methods="GET" url-mapping="/employee">
      <inSequence>
         <log>
            <property name="====== API IN =====" value="==== INSEQ ===="/>
         </log>
         <sequence key="conf:/Tconf"/>
         <property name="POST_TO_URI" value="true" scope="axis2"/>
         <send>
            <endpoint>
               <http method="GET" uri-template="http://localhost:9000/{uri.var.service.host}/{uri.var.service.path}?USERNAME={uri.var.service.user}&amp;PASSWORD={uri.var.service.pass}&amp;ioName={uri.var.service.wfName}"/>
            </endpoint>
         </send>
      </inSequence>
   </resource>
</api>

Thanks.