XML as a Common Data Format of Web Service

Sunday 3 July 2016

XML as a Common Data Format of Web Service

Using XML as a Common Data Format of Web Service

Different types of computers can store the same values by using different internal representations— computers based on a “big-endian” 32-bit processor use a different format for numeric data than a computer based on a “small-endian” 32-bit processor for example. So, to share data successfully between applications running on different computers, developers had to agree on a common format for that data that was independent of the architecture of the computer they were using. To cut a long story short, the currently accepted universal data format is eXtensible Markup Language, or XML. XML is text-based and human-readable (just), A uniform data representation and exchange mechanism. The prefect choice for enabling cross-platform data communication in Web Services.
 In case you have not seen XML data before, here is an example:
<?xml version=1.0?>
<contact>
   <name>John Doe</name>
   <address>2 Backroads Lane</address>
   <country>New York</country>
   <phone>045935435</phone>
   <email>john.doe@gmail.com</email>
</contact>
Without trying too hard, you can probably guess what this data actually means. An application that needs to send information about a person to another application could format the data in this way, and the receiving application should be able to parse the data and make
sense of it. However, there is more than one way to represent this information by using XML.
There are many other variations possible as well. How does an application know how to format
data so that another application can read it correctly? The answer is that both applications
have to agree on a layout. This layout is referred to as the XML schema for the data. So, by adopting XML and schemas as a common data format, applications running on different computers can at least understand the data that they are using.

Sending and Receiving Web Service Requests

A sample request  message format shown below picture


A sample response message format shown below picture

Using XML and XML schema to format data enables Web services and client applications to pass data back and forth in an unambiguous manner. However, client applications and Web services still need to agree on a protocol when sending and receiving requests. Additionally, a client application needs to be able to know what messages it can send to a Web service and what responses it can expect to receive. Web services (More details on Web service) and client applications communicate with each other by using the Simple Object Access Protocol, or SOAP (More details on SOAP ).