Tags

, , ,

What are Web Services?

A: Exposed services on the Web for use / integration. With it, you can make communication between different applications.

Example: Zip Code, Gmail API (Gmail service)

Companies create their application and provide specific services of this application so that you can use. For example: it is common today to use Facebook API¹ to register / log in to an external site. You can also use the posting service of Facebook and so on.

¹ – API (Application Programming Interface) – It’s a utility to assist in the development.

Main types of Web Service

  • SOAP, which uses the XML message exchange defined by contract.
  • REST, which uses requests to an URI to access the service.

Note:

  • URI – Uniform Resource Identifier is a sequence of characters that define a resource. On the Internet, an example of a resource is the URL. All URL is an URI.

SOAP

Server Side (Web Service Creation):

  • Defines the service to be offered, the access to it.
  • After the entire defined contract, must create the WSDL², which can be summarized as the formal contract, and in some cases also creates the XSD³.

² – WSDL is the utilization contract of SOAP service. It defines the parameters received, return, operations (services) available and other information.
³ – XSD is the file that defines how XML can be structured. We call this structure model: schema.

Client Side (Access to Web Service):

The SOAP client briefly uses the following model:

  • First, you must get the WSDL from the application with the service that you want to use.
  • Creates a SOAP envelope for the request, following the standards set by the creation of the Web Service in the WSDL.
  • The SOAP envelope contains a Header and Body. Inside the Body are the parameters to be passed to the Web Service.
  • The Web service returns a SOAP envelope with the result of the call. Here comes the answer of the service.

A tool used for these requests is SoapUI.

REST

Server Side (Web Service Creation):

  • Defines the service to be offered, the access to it.
  • After all set, when the application is running it’s already possible to access by the defined protocol (usually HTTP).

Notes:

  • You can use a similar approach with SOAP using WADL, which has a similar approach to WSDL. However, this approach is rarely used.
  • Very important to know that despite the REST use with the HTTP protocol, REST is not exclusive of this protocol, but it is the only protocol 100% compatible.

Client Side (Access to Web Service):

The REST client briefly uses the following model:

  • First, you must get the URI from the application with the service that you want to use.
  • Run the call to this URI, with the parameters, if needed.
  • The application returns the status of the response and, if necessary, the response body.

A tool used for these requests is the Poster (Chrome and Firefox Plugin).

Final notes

  • SOAP uses XML for the exchange of messages.
  • REST uses JSON (basically a JavaScript object) more often for this exchange of messages, but you can use XML, text and many other types.
  • REST has grown due to its simplicity.
  • As mentioned, you can use schema for XML, but there is also schema for JSON (JSON Schema).
  • The APIs for programming languages make easier the development related to Web Services.

If you use Web Services, I would like to know if you use SOAP or REST, which prefer to use and how do you use.

That’s it, folks. I hope you enjoyed.

Advertisements