java - Passing dynamic query params and path params in http request connector -


i looking pass list of query params , path params http request mule connector. input coming connector list of pojo contains value of query , path params.

the http request connector looks below:

<http:request config-ref="http_request_configuration" path="/rates/api/v1/rates/{in}.csv" method="get" doc:name="end_http request"> <http:request-builder>     <http:query-param paramname="api_key"         value="abcde" />     <http:query-param paramname="quote" value={target_currency} />     <http:query-param paramname="date" value={date} />     <http:query-param paramname="fields" value="averages" />     <http:uri-param paramname="in" value={source_currency} /> </http:request-builder> 

the pojo class looks this:

public class data {      private string sourcecurrency;     private string targetcurrency;     private string date = (new simpledateformat("yyyy-mm-dd")).format(new date());      public data() {     }      public string getsourcecurrency() {         return sourcecurrency;     }      public void setsourcecurrency(string sourcecurrency) {         this.sourcecurrency = sourcecurrency;     }      public string gettargetcurrency() {         return targetcurrency;     }      public void settargetcurrency(string targetcurrency) {         this.targetcurrency = targetcurrency;     }      public string getdate() {          return date;     } } 

if input http request connector object of data class how set query , path params.

can please me example?

thank you.

sumved

first have assign value object data (which payload) required variables (targetcurrency, date, sourcecurrency) , have assign value of variables query params , path params. here have example:

<?xml version="1.0" encoding="utf-8"?> <mule xmlns="http://www.mulesoft.org/schema/mule/core"       xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"       xmlns:spring="http://www.springframework.org/schema/beans"       xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"       xmlns:http="http://www.mulesoft.org/schema/mule/http"       xmlns:jms="http://www.mulesoft.org/schema/mule/jms"       xmlns:vm="http://www.mulesoft.org/schema/mule/vm"       xmlns:file="http://www.mulesoft.org/schema/mule/file"       xmlns:ftp="http://www.mulesoft.org/schema/mule/ftp"       xmlns:db="http://www.mulesoft.org/schema/mule/db"       xmlns:mule-xml="http://www.mulesoft.org/schema/mule/xml"       xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey"       xmlns:json="http://www.mulesoft.org/schema/mule/json"       xmlns:ws="http://www.mulesoft.org/schema/mule/ws"       xmlns:smtps="http://www.mulesoft.org/schema/mule/smtps"       xmlns:email="http://www.mulesoft.org/schema/mule/email"       xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"           xsi:schemalocation="         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd         http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd         http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd         http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd         http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd         http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd         http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd         http://www.mulesoft.org/schema/mule/ftp http://www.mulesoft.org/schema/mule/ftp/current/mule-ftp.xsd         http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd         http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd         http://www.mulesoft.org/schema/mule/jersey http://www.mulesoft.org/schema/mule/jersey/current/mule-jersey.xsd         http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd         http://www.mulesoft.org/schema/mule/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.xsd         http://www.mulesoft.org/schema/mule/smtps http://www.mulesoft.org/schema/mule/smtps/current/mule-smtps.xsd         http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/current/mule-email.xsd            ">      <http:listener-config name="http_listener_configuration" host="localhost" port="8081" doc:name="http listener configuration">         <http:worker-threading-profile maxthreadsactive="64" />     </http:listener-config>      <http:request-config name="http_request_configuration" host="localhost" port="8081"/>      <flow name="testingflowservice">         <http:listener config-ref="http_listener_configuration" path="/service/{waittime}/*" doc:name="http"/>         <logger message="query params: #[message.inboundproperties.'http.query.params']" level="info" doc:name="log failure"/>         <logger message="uri params: #[message.inboundproperties.'http.uri.params']" level="info" doc:name="log failure"/>     </flow>      <flow name="testingflowclient">         <http:listener config-ref="http_listener_configuration" path="/client/*" doc:name="http"/>         <logger message="before transformation" level="info" />         <json:json-to-object-transformer returnclass="com.testing.domain.generalrequest" />         <set-variable variablename="processtypejob" value="#[payload.processtypejob]"/>         <set-variable variablename="waittime" value="#[payload.waittime]"/>         <logger message="after transformation" level="info" />         <json:object-to-json-transformer/>         <http:request config-ref="http_request_configuration" path="/service/{waittime}" method="post"                          responsetimeout="50000000">             <http:request-builder>                 <http:query-param paramname="api_key"                     value="abcde" />                 <http:query-param paramname="processtypejob" value="#[processtypejob]" />                 <http:query-param paramname="fields" value="averages" />                 <http:uri-param paramname="waittime" value="#[waittime]" />             </http:request-builder>         </http:request>     </flow>  </mule> 

and class i'm using:

package com.testing.domain;  import java.util.list;  public class generalrequest {     private string processtypejob;     private string waittime;     private list<string> processids;     private string processtypegroup;     private list<jobconfiguration> jobconfigurations;      public string getprocesstypejob() {         return processtypejob;     }     public void setprocesstypejob(string processtypejob) {         this.processtypejob = processtypejob;     }     public list<string> getprocessids() {         return processids;     }     public void setprocessids(list<string> processids) {         this.processids = processids;     }     public string getprocesstypegroup() {         return processtypegroup;     }     public void setprocesstypegroup(string processtypegroup) {         this.processtypegroup = processtypegroup;     }     public list<jobconfiguration> getjobconfigurations() {         return jobconfigurations;     }     public void setjobconfigurations(list<jobconfiguration> jobconfigurations) {         this.jobconfigurations = jobconfigurations;     }     public string getwaittime() {         return waittime;     }     public void setwaittime(string waittime) {         this.waittime = waittime;     }    } 

for more information can see next link: https://docs.mulesoft.com/mule-user-guide/v/3.7/http-request-connector


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -