XML vs SOAP vs WSDL

XML

The important elements to consider in SOAP services are XML, XSD and namespaces formats.

XML is a format for exchanging messages or configuration but you have the freedom to use tags however you want (unlike HTML which are already preset). XSD restricts us that freedom of XML with the schemes it provides us, each one can create their own schemes or there are other schemes already created such as the W3C. The namespaces allow us to identify the elements and attributes in an XML document, it does so through groupings (in OOP it would be similar to packages).

SOAP

SOAP stands for Simple Object Access Protocol. It is a specification from W3C the World Wide Web Consortium. A specification usually is a set of rules in case of soap. These rules come in form of a XML document . W3C defines all these elements that we can use to send out Web services requests and receive the responses back.

The soap envelope is the root element in the soap namespace. SOAP header one of its child element is used to send Meta information.The body is where the entire payload or the webservices request will go in. And even the response payload that comes back from the webservice provider comes back in this body.

We can use the Soap fault element which is an optional element. Which is the child element of the soap body and we can send the error information back to the user or the application that is consuming the webservice. When we throw exception, as a webservice  provider, when we throw exception those are exceptions by default will be converted into soap fault and sent back to the client by webservices stacks like Apache CXF, web logic, websphere. 

The soap header is not used to send the payload information or the request and response but it is usually used to send meta formation and it is used by all the Web services standards or most of the webservices standards.

WSDL

WSDL stands for Web Services Description Language. WSDL file is a contract between the web services provider and the consumer. It is a XML file with a dot wsdl extension.There are two things which a wsdl file provides. One it tells, what this particular webservice provides, two how it provides it and how a consumer can consume these webservice.

What message a consumer should send in the request and what response will go back as the webservice response back to the consumer?

Based on these two, the wsdl file is divided into abstract portion and the physical portion. The  abstract portion which tells what this webservice provides is comprised of four elements. The types, messages, operation and porttype.The physical section which comprises of two elements binding and service tell how to consume this service from the consumer.

WSDL Styles

We can specify a soap binding style by using the style attribute on the soap binding element in a wsdl file, for example document/literal is one of the styles you should remember that there are three important things that will be impacted depending on the style will choose. 

  1. How the soap payload the message inside the soap body element. 
  2. Whether the entire soap body can be validated against the schema that will use in the wsdl is determined by the time we use. 
  3. Whether the operation name the name of the method, webservice method that should be invoked whether it is a part of the Soap Body is also determined by that document liberal style.

So we basically, have four types or four styles in which we can define a binding. So it is RPC encoded or RPC literal, document encoded and document literal.

Referencias

Comentarios