Mule ESB - How to create a HTTP request with POST method (sending parameters along) -



Mule ESB - How to create a HTTP request with POST method (sending parameters along) -

short: want post couple of parameters (like user=admin, key=12345678) using post method php page (like localhost/post-debug.php). script read $_post values , whatever.

my questions are:

1. how can illustration below work?

2. how can create map payload post parameters json encoded payload , send php script?

below isolated case trying running (the parameters "read" http endpoint). calling straight browser next url:

http://localhost:8081/httppost?user=admin&key=12345678

the underlying xml:

<?xml version="1.0" encoding="utf-8"?> <mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="ce-3.3.1" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation=" http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd "> <flow name="httpposttestflow1" doc:name="httpposttestflow1"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="httppost" doc:name="http"/> <http:body-to-parameter-map-transformer doc:name="body parameter map"/> <echo-component doc:name="echo"/> <http:outbound-endpoint exchange-pattern="request-response" host="localhost/post-debug.php" port="80" contenttype="application/x-www-form-urlencoded" doc:name="http" /> </flow> </mule>

i using mulestudio 1.3.2, mule esb v.3.3.

i've reviewed many similar questions none got me on right track.

here solution question 2 (answering question 1 won't help):

<flow name="httpposttestflow1"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="httppost" /> <json:json-to-object-transformer returnclass="java.util.map" /> <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="80" path="post-debug.php" method="post" contenttype="application/x-www-form-urlencoded" /> <copy-properties propertyname="*" /> </flow>

i've used next check works fine:

curl -h "content-type: application/json" -d '{"param1":"value1","param2":"value2"}' http://localhost:8081/httppost

note utilize copy-properties propagate response headers php script invocation original caller. remove if don't care.

mule mule-studio

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -