You can see below my project. I send data to a web service and when i'm testing with postman, i get the response of the web service, which is in json format: {"success":0,"failed":1}. Now i want to get this reponse in my mule because i need to complete a test with the result. Thank you in advance. Test with postman:
Now i will add "Choice component" if success = 1 and failed = 0 then "logger with a message it's ok" if not i will do another thing.
After http outbound endpoint put <json:json-to-object-transformer returnClass="java.util.List" doc:name="JSON to Object"/>
and then in choice component the that expression #[message.payload.success]
is 1 and #[message.payload.failed]
is 0 then log ok or else do other thing
UPDATE
After you get the response as {"success":0,"failed":1}
put <json:json-to-object-transformer returnClass="java.lang.Object" doc:name="JSON to Object"/>
and extract the values in following expression MEL :-
#[message.payload.success] and #[message.payload.failed]
and then in choice component the that expression #[message.payload.success]
is 1 and #[message.payload.failed]
is 0 then log ok or else do other thing