0
votes

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. enter image description here Test with postman:

enter image description here 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.

1
Please add the HTTP request you create with Postman (including headers, params, etc) since that is what you want to do with mule now.afelisatti
Thank you @afelisatti for your reply. you can see now my updated question.Rajeun
if you are already getting the response from this web service, you can set payload after the http outbound with #[message.payload] MEL expression wrapped with http response builder .. that will workAnirban Sen Chowdhary
@AnirbanSenChowdhary this is the first time I work with these components so if you can tell me where to add what is missing or give me an example, I would be grateful.Rajeun
i tried this: pastebin.com/qkX9pkEc . but it didn't work, any answer please.Rajeun

1 Answers

1
votes

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