How To Set Variable And Payload In MuleSoft

This article is the continued part of the MuleSoft series and the next part of the last posted article. Before jumping into this article, I highly recommended reading these articles for better understanding.

If you would like to understand the basics of MuleSoft, refer to these articles before going next:

Getting Started

  • First, open Anypoint Studio and Create a New Mule Project.
    Set Variable and Payload in MuleSoft
  • Enter the project name and select runtime and project location and click Finish button.
    Set Variable and Payload in MuleSoft
  • Next add a New Mule Configuration file for global settings.
    Set Variable and Payload in MuleSoft
  • Give the file name global and click Finish.
    Set Variable and Payload in MuleSoft
  • Next go to global.xml file and click on Global Elements tab and click Create button and select HTTP Listener config and click OK.
    Set Variable and Payload in MuleSoft
  • Enter the required details like listener name, protocol, host, and port. I am keeping everything as default and click OK.
    Set Variable and Payload in MuleSoft
  • Global configuration is done for HTTP listener, let’s work on Message flow. Drag and drop HTTP Listener from HTTP Palette to Message Flow.
    Set Variable and Payload in MuleSoft
  • Go to HTTP listener properties and provide listener name, Connector configuration (Which we setup in global.xml file) and Path (Will get call from Postman).
    Set Variable and Payload in MuleSoft
  • Drag and drop Set Variable from Core palette.
    Set Variable and Payload in MuleSoft
  • Set variable Name and Value.
    Set Variable and Payload in MuleSoft
  • Drag and drop Set Payload from Core palette.
    Set Variable and Payload in MuleSoft
  • Provide display name Settings value.
    Set Variable and Payload in MuleSoft
  • Finally, drag and drop Logger to see the log.
    Set Variable and Payload in MuleSoft
  • Set Logger properties.
    Set Variable and Payload in MuleSoft
  • That’s it. Now time to deploy the application. Right click on file and click Run As Mule Application.
    Set Variable and Payload in MuleSoft
  • Once you see the message Deployed, that means everything is good and application is deployed.
    Set Variable and Payload in MuleSoft
  • Open Postman to see the result.
    Set Variable and Payload in MuleSoft

Everything is looking good.

Conclusion

In this article, we learned how to set variable and set payload in MuleSoft and how to see the variable result in Postman.


Similar Articles