SOAP web service architecture

SOAP is a messaging protocol that is used to exchange data in a distributed environment in XML format. SOAP is a standard XML where data is transported in an envelope format called SOAP Envelope, as shown in the following diagram:

SOAP Envelope for web service data exchange

As shown in the preceding diagram, SOAP Envelope contains two parts:

  • SOAP Header: The SOAP header provides information on how a recipient of a SOAP message should process it. It contains authorization information to deliver the message to the right recipient and for data encoding.
  • Message Body: The message body contains the actual message in Web Services Description Language (WSDL) specification. WSDL is an XML format file that describes the Application Programming Interface (API) contract with the message structure, API operations, and server Unique Resource Locator (URL) address. Using a WSDL service, a client application can determine where a service is being hosted and what functionality it can perform.

The following code shows an example of a SOAP envelope XML. Here, you can see both the header and message wrap up under the SOAP envelope:

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">

<env:Header>

<n:orderinfo xmlns:n="http://exampleorder.org/orderinfo">

<n:priority>1</n:priority>

<n:expires>2019-06-30T16:00:00-09:00</n:expires>

</n:orderinfo>

</env:Header>

<env:Body>

<m:order xmlns:m="http://exampleorder.org/orderinfo">

<m:getorderinfo>

<m:orderno>12345</m:oderno>

</m:getorderinfo>

</m:order>

</env:Body>

SOAP commonly uses HTTP, but other protocols such as SMTP can be used.

The following diagram shows details about a message exchange in a web service using SOAP. Here, the web service client sends the request to the service provider who hosts the web service, and receives the response with the desired result:

SOAP-based web service

In the preceding diagram, the client is an e-commerce website user interface. The user wants their order information and hence sends the SOAP message in the XML-format to the application server with the order number. The application server hosts the order service, which then responds with the customer's order details.

In a SOAP-based web service, the service provider creates an API contract in the form of WSDL. WSDL lists all of the operations that web services can perform, such as providing order information, updating orders, deleting orders, and more. The service provider shares WSDL with web service client team, using which the client generates an acceptable message format, sends data to the service provider, and gets the desired response. The web service client fills the values in the generated XML message and sends it across to the service provider with authentication details for processing.

The implementation of a SOAP-based web service has a higher complexity and requires more bandwidth, which can impact web application performance, such as page loading time, and any major changes in the server logic require all clients to update their code. REST was created to address SOAP-based web service problems and provide a more flexible architecture. Let's learn more about RESTful architecture and why it is becoming widely popular.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.152.87