问题
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP" contentType="application/x-www-form-urlencoded" path="getDetails" />
<object-to-string-transformer doc:name="Object to String"/>
<logger message=" Logging ...... #[message.payload]" level="INFO" doc:name="Logger"/>
<logger level="INFO" message=" Logging mule.......#[message.payloadAs(java.lang.String)]" doc:name="Logger"/>
<logger level="INFO" message="Logging demo .......... #[payload]" doc:name="Logger"/>
i invoke thru chrome rest client
http://localhost:8081/getDetails
METHOD : post
below is json data
{
"id": "1", "firstName": "xyz", "lastName": "abc", "address":"xy"
}
whatever json data i passed , i just want to print for processing . but In logging it shows null payload
any correct solutions are welcome
回答1:
Strange, but I tried your scenario by following :-
<flow name="Flow1" doc:name="Flow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP" contentType="application/x-www-form-urlencoded" path="getDetails" />
<object-to-string-transformer doc:name="Object to String"/>
<logger message=" Logging ...... #[message.payload]" level="INFO" doc:name="Logger"/>
<logger level="INFO" message=" Logging mule.......#[message.payloadAs(java.lang.String)]" doc:name="Logger"/>
<logger level="INFO" message="Logging demo .......... #[payload]" doc:name="Logger"/>
</flow>
And you can see I am able to log the values :-
回答2:
Your code is absolutely correct. As Anirban pointed out, you may be making mistake while invoking the service. I tried invoking this service using postman plugin in Chrome and selected post with raw XML and it worked fine. Please try with postman and confirm if you still have the same issue.
来源:https://stackoverflow.com/questions/29445886/mule-post-json-data-to-mule-endpoint-url