If you would like to understand the basics of MuleSoft, refer to these articles before going next:
Database Schema and Procs
![How to Call Stored Procedure with MuleSoft]()
Stored Proc
![How to Call Stored Procedure with MuleSoft]()
Before proceeding further, you must connect to Azure SQL Database and learn how to create and set up a new MuleSoft project. You need to go through this article because I don’t want to do the same duplicate work in this article. Here is the article link:
Now let’s pretend the connection is done and the MuleSoft project is setup. Now drag and drop Listener (HTTP) from Mule Palette and provide Display Name, Connector configurations, and Path. I am keeping everything default except changing the port from 8081 to 8082 because 8081 port is already in use for me.
Listener properties
![How to Call Stored Procedure with MuleSoft]()
Connector configuration
![How to Call Stored Procedure with MuleSoft]()
Now let’s drag and drop the Database> Stored procedure into Message flow from Mule Palette and provide the given properties:
- Display Name – Title of the Database.
- Connector Configuration – Configuration of your Database
- SQL Query Text - Call stored procedure name as we do not use any inline query in this sample.
![How to Call Stored Procedure with MuleSoft]()
These are my Connector configuration properties.
![How to Call Stored Procedure with MuleSoft]()
All looks good so far. Now let’s drag and drop Transform Message (Core) from Palette to Message flow and setup Output Payload as JSON.
![How to Call Stored Procedure with MuleSoft]()
Last but not least, let’s run and deploy the project before testing the output in Postman.
![How to Call Stored Procedure with MuleSoft]()
All looks good, the project deployed without any warning or error message. Time to test the output in Postman.
![How to Call Stored Procedure with MuleSoft]()
Everything is working perfectly, and the result set is in JSON format.
Conclusion
In this article, we learned how to call SQL Stored Procedure in MuleSoft and get and display data in JSON format.