Here is the solution for 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 the following to check it works fine:
curl -H "Content-Type: application/json" -d '{"param1":"value1","param2":"value2"}' http://localhost:8081/httpPost
Note that I use copy-properties
to propagate all the response headers from the PHP script invocation back to the original caller. Remove it if you don't care.