Tuesday, December 18, 2018

Understanding Web Services, APIs and Architectural Pattern



Since I started my career in testing, I hear and see these words frequently -- 'Web Services', 'APIs', 'Service Oriented Architecture', and 'SaaS'. In recent seven years, I heard word 'Microservices' quite frequently. 

In overall, when I talk to practicing testers, we hear this question during discussion in knowing the differences and understanding of same.  I too had this confusion and questions.  I worked upon it to know them and trying my best to understand what they mean. Today I test them and continue to update myself while I learn what they mean in its existence and purpose.  

In this post, I share what I understand for them by saying the differences I have figured out.  So that, it helps other testers or SDETs.


Web Services


Before getting into word 'Web Services', I want to understand what the word 'web' and 'services' mean. The word 'web' - interconnected systems over network. Then what do word 'services' mean in this context? I learn - services is the endpoint of a connection; it has computer systems to support the connections that it offers.  Then Web Services is - the technologies that allow for making the connections over web and its protocols. Thereby we connect the services together using Web Services.

The Web Services are offered by making use of:

  • SOAP (Simple Object Access Protocol);
  • REST (REpresentational State Transfer it is a representation style of architecture, and not a protocol );
  • and, other web technologies which includes protocol and architecture pattern


Service Oriented Architecture (SOA)


SOA is collection of services, where services communicate with each other.  It can exchange data from simple to complex form between one or more services to accomplish a purpose of activity (i.e. request).  Now we see that service - i.e. a function to be well thought, defined,  and not to depend on state and context of other services.  The service will have consumer (consumer of service by requesting for it) and provider (provider of service as response to request).  Note that service provider also can be a consumer based on contexts.

With this I understand, SOA is a software architecture pattern. The service provider provides the service to consumer over communication protocol.

Note: Few protocols which are commonly used - HTTP and SOAP.  I remember the days where I tested CORBA based services.



Application Program Interface (API)


Thinking in this perspective, I believe, it helps understanding it better -- information hiding. The 'hiding' here means, independent modules which can communicate with each other and exchange the only information which is required. Thereby accomplishing the modularity with independent modules.

This enables for the creation of interface which can be used by other software systems (i.e. service consumers) to access the data and update if required. 

The APIs usually will be implemented using Web Services with help of SOAP,  HTTP, REST and other protocols and architectural representational styles.  When said REST APIs, it means the APIs adhering to the standards of REST.



Microservices


It is an architectural style which structures the application as a collection of services. That means, an application can have multiple services which are -- independently deployable; not coupled to other services very tightly; which can be tested easily in isolation to other services; easily maintainable by a programmer; and it represents the business components i.e. business's services.

For example, the search in https://amazon.in, is one service; and, the order fulfilment is another service. Either of these service is being down does not affect other service in its functional operation. This is one benefit of microservices architectural style. 



Pictorial Representation




In the above pic,

  • how two end points (service consumer & service provider) communicates is with the help of Web Services. Web Services is a concept how two end communicates in a view.
  • Underlying system and data it processes, is not visible to service consumer. The service consumer just sees an interface i.e. API through which the specific service's request is made and it gets the specific response. The API does not expose other functional behaviour of underlying system and data it processes.
  • The way these services are structured and organized forms architectural pattern of the system. It can be any architectural pattern and few commonly heard are -- SOA, Microservices.
  • How consumer talks to interface (API) changes quite often and not the interface. Likewise, how the service has to be provided by service provider changes than the API i.e. interface.


Relating a daily life example


Air ticket enquiry and booking system:
  • Airline and consumer are two end points. They can communicate to each other via phone call, email, chat, or in person.  There is a protocol which defines how this communication to happen between the two end points.  A service is provided to a consumer.  In tech, relate this to Web Services.
  • Different protocols for different communication types i.e. I can't communicate as I do in email when I talk to airline staff in airport.  Relate this to SOAP or REST, to start.
  • To enquiry about my customer membership with airline, I need to talk right person. A front desk staff might not be able to provide this service.  Relate this to API i.e. specific service request and an interface to it.  I don't see how they the info to me; all I see is the details of my membership and share it with me.
  • If the check-in system of the airline is not functional, still the ticketing system of that airline can be used to buy a ticket. This is an example of microservices assuming 'check-in' and the 'ticketing system' are two microservices which are not dependent on each other, though they interact to complete the business need.
  • Having distinguished services and staff assisting for it in airport, so that consumer can go and consume what is needed, will sum up to Service Oriented Architecture style.