I have a service endpoint http://xyzhost:port/greet123 and it accept request parameters salary and age and I need to pass query parameters as part of request like http://xyzhost:port/greet123?salary=100000&age=32 . I am new to mule , I am successful in invoking other service endpoints which do not have request parameters but when there are query parameters to be passed I am unsuccessful to set query parameters and to get proper response. I am using mule 3.3 version.Below is my mule flow. In mule flow before hitting service endpoint using http:outbound-endpoint I am using custom-transformer (custom request transformer) to set query parameters to outbound request scope. But no luck , unable to set query parameters as part of request due to that I got 400 - Bad request as response from service endpoint. Even I also tried using in mule flow. Can anyone please suggest me the way how to set query parameters to service endpoint.
Below is mule flow xml file and custom request transformer
<http:connector name="ClientOutboundHttpConnector">
<service-overrides sessionHandler="org.mule.session.NullSessionHandler"/>
</http:connector>
<!-- Below is the flow for sample rest endpoint -->
<custom-transformer
name="SampleRequestTransformer"
class="com.example.SampleRequestTrasformer" />
<custom-transformer
name="SampleResponseTransformer"
class="com.example.SampleResponseTrasformer" />
<flow name="sampleRESTFlow" doc:name="sample rest Flow">
<inbound-endpoint address="servlet://getDetails" exchange-pattern="request-response" connector-ref="muleCXFServletConnector"
transformer-refs="SampleRequestTransformer" responseTimeout="600000" />
<http:outbound-endpoint
address="http://xyzhost:port/greet123"
connector-ref="ClientOutboundHttpConnector"
exchange-pattern="request-response"
contentType="application/x-www-form-urlencoded"
keep-alive="true"
responseTimeout="360000"
responseTransformer-refs="InputStreamToStringTransformer"/>
<logger
message="MappingServer Response after reading stream=#[payload]"
level="INFO" />
<transformer ref="SampleResponseTransformer" />
<transformer ref="clientErrorResponseTransformer" />
</flow>
Below is the code for custom request transformer
@Override
public Object transformMessage(MuleMessage message, String arg1)
throws TransformerException {
// TODO Auto-generated method stub
Object payload = message.getPayload();
Map<String,String> queryParams= new HashMap<String,String>();
queryParams.put("salary", "400000");
queryParams.put("age", "32");
message.setProperty("Content-Type", "application/x-www-form-urlencoded", PropertyScope.OUTBOUND);
message.setProperty("mimeType","application/x-www-form-urlencoded",PropertyScope.OUTBOUND);
message.setProperty("http.method", "POST", PropertyScope.OUTBOUND);
message.setProperty("http.query.params",queryParams, PropertyScope.OUTBOUND);
return message;
}
}```