mule post json data to mule endpoint url

自作多情 提交于 2019-12-25 02:07:20

问题


<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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!