Reputation: 46
We have many Mule flows hosted that we invoke via our intranet Apache/PHP server, one that we use specifically in conjunction with Mule ESB. Typically, for these flows I would invoke a Mule flow via an HTML form POST to my Mule ESB server/port/path to begin the Mule flow's kickoff.
Within the Mule flow, instead of an output phase involving creating http output/combined with data using Mule, I would simply write data to a RDBMS in JSON format, and then finish the flow using the HTTP Response Builder to redirect the reply to a different url and querystring (but still hosted on the same Apache/PHP server that i started on), also using a redirect 30x to invoke the PHP code in the HTTP Response Builder.
With HTTP Response Builder deprecated in 3.6, what would be the most straightforward way without new coding to replace the HTTP response Builder 30x redirection with the new 3.6 HTTP operation-based Connector? Is it really as straightforward as setting the followRedirects property as described in http://www.mulesoft.org/documentation/display/current/Migrating+to+the+New+HTTP+Connector?
Upvotes: 1
Views: 465
Reputation: 699
I hit a similar issue and was able to replicate the same behaviour of the now deprecated response builder in the new HTTP lsitener/requester (Mule 3.7.0) using the proxy pattern as already suggested in another post:
How to implement Mule HTTP GET Method redirect?
The steps to do this were:
1) Define a proxy pattern:
1.1) inbound address is http://localhost:8082/proxy, 1.2) outbound is address of remote web service 1.3) set a transformer-ref on the proxy to return an object of type 'java.util.HashMap()' (in my case this was left empty as the request data was in URI params)
2) Create a flow with http listener to accept requests and http requester with address same as proxy inbound
Code snippet for the example here:
<pattern:http-proxy name="http-proxy-sample" transformer-refs="str2map"
inboundAddress="http://localhost:8082/proxy"
outboundAddress="https://example.com" />
<expression-transformer expression="#[new java.util.HashMap()]" name="str2map" doc:name="Expression"/>
<flow name="redirect">
<http:listener config-ref="HTTP_Listener_Configuration"
path="/redirectMe" allowedMethods="GET" doc:name="HTTP">
</http:listener>
<http:request config-ref="HTTP_Request_Configuration2"
path="/proxy" method="GET" doc:name="HTTP">
</http:request>
</flow>
HTH.
Upvotes: 0