Implementing Your First API with Anypoint Studio: A Beginner’s Guide
Mule is an integration framework, with the help of which one can easily integrate different applications/tools using different connectors/components provided by MuleSoft. Mule ESB supports powerful features/mechanism like REST, SOAP, JMS, Salesforce, Dataweave & cloudhub etc. In the article, I’m going to present you the way to implement basic Mule application using Anypoint Studio. Below are tools and their version which I’m using in order to implement it:
- Anypoint Studio – 7.4.2
- Mule Runtime – 4.2.2
- Postman or any other rest client
Follow the below steps in order:
Step 1: Open Anypoint Studio, right click on the Project explorer and go to New > Mule Project
(Alternate is to click on File from the top bar, New > Mule Project)
Step 2: In newly opened window, define your application name and select the runtime version for
your application. Let other things remain same for now, and Click on Finish.
Step 3: Once the project structure is generated in Project explorer, open the {appname}.xml (In my case it is: basicapp.xml)
Step 4: Drag a http listener connector from Mule Palette
Step 5: Click on the HTTP Connector and you can find HTTP Attributes in the below screen. We
need to configure some details of the HTTP Connector by clicking on + sign.
Step 6: By default, configuration will be set for http (port and host), you can also modify it based on
your requirements. Also, add the base path like below and click on OK
Step 7: Set the Path as /* (It will allow anything after basepath) and define the method in Advanced > Allowed Methods as GET
Note > If you left allowed method as empty, it will accept all the methods.
Step 8: Drag a Set Payload connector from Mule Palette
Step 9: Click on Set Payload Connector and set the value.
Step 10: In order to run this application, right click on Project and select Run As > Mule Application
(You can also right click on the mule flow and select “Run Project”)
Step 11: You can see the status of your deployed application in console tab.
Step 12: Now it’s time to test your application using postman, create below request in your postman
Method: GET
Endpoint URL: http://{host}:{port}/api
Click on send button.
Once you get the result, make sure you stop the application by Right clicking on your flow and select
Stop Project.
Comments are closed.