This tutorial introduces you to Web Service and creating a high-security consumption of Web Service using SOAP in MuleSoft Anypoint Studio.
What are Web Services?
- Services available over the web are called Web Services.
- Web Services enable communication over the web.
- Provides a standard format/protocol for communication.
- It is a platform-independent communication.
- Using Web Services, two different applications, the first implementation in Java and other implementation on C++, can talk to each other.
For better clarity, we can take the example of ordering food in a restaurant. The waiter acts as a medium between customer and kitchen by conveying the order to chef and getting food delivered over the table. In the same way, a web URL acts as a medium of communication whenever we search or do anything over the Web to get the desired results.
Lets Look at Kayak, an online travel agency and a fine example of web services. When we search for flights on the panel for the flights on desired date and time then our request is redirected to various APIs. All these airlines take the response and check out for flights, their availability and a response is sent back to Kayak from all these airlines. Further, displaying results we get from these APIs in a readable format.
Moving on to SOAP:
SOAP plays a central role in the Service Oriented Architecture (SOA) approach for software design and development
- SOAP stands for Simple Object Access Protocol.
- SOAP is an application communication protocol.
- SOAP is a format for sending and receiving messages.
- SOAP is platform-independent.
- SOAP is based on XML.
- SOAP is a W3C recommendation.
SOAP Message Structure:
Advantages of SOAP:
- WS Security: SOAP defines its own security known as WS Security.
- Language and Platform independent: SOAP web services can be written in any programming language and executed in any platform.
Disadvantages of SOAP:
- Slow: SOAP uses XML format that must be parsed to be read. It defines many standards that must be followed while developing the SOAP applications. So it is slow and consumes more bandwidth and resources.
- WSDL dependent: SOAP uses WSDL and doesn’t have any other mechanism to discover the service.
Consuming SOAP through MuleSoft
We are going to consume a SOAP web service and implement different operations with the web service.
[Make sure you have MuleSoft Anypoint Studio 7+ installed on your system.]
Step 1: Make a new project in your Any point Studio by clicking on File>New>Mule Project.
Step 2: Give a Title to the new project. We have named it consuming_soap in this example.
Step 3: Add file module by clicking on add module in the mule pallet as Add Modules>Web Service Consumer.
Step 4: Make the desired flow with the required components shown in the flow below.
Step 5: Set various connectors configuration as below.
You can directly use the XML code from below to set the desired configurations.
Step 6: Hit the URL from postman to see the output we want.
Consuming SOAP web service using MuleSoft is as easy as getting results from the web by searching anything. It is also a high security consumption of web service as we are using SOAP web service. Any MuleSoft Developer can use this flow to consume the SOAP web service using MuleSoft.
Find more MuleSoft best practices here at : https://www.caeliusconsulting.com/blogs/