Web API, Services and Architectures

Unlock the power of modern API design with a clear guide to web APIs, microservices, and service-oriented patterns for scalable, flexible, and maintainable applications.

Ceyhun Enki Aksan
Ceyhun Enki Aksan Entrepreneur, Maker

Our understanding and requirements regarding the web enable us to develop better approaches for creating more efficient systems in every possible way.

Continuing from REST and RESTful, which is part of the core conceptual series on web development, I’m now consolidating several interrelated concepts into a single article. In this article, I’ll explore APIs and architectural patterns, presenting their alternatives and/or complementary aspects. My goal is to help you form a basic understanding of these terms, similar to mine. For further reading, examples, and more detailed explanations, please refer to the references section. During the article’s composition, I encountered references to conflicting or different technologies, principles, and environments, so I’ve tried to keep the context as limited as possible. In this regard, if any statement requires addition or revision, a comment will suffice. Thus, let’s begin.

WCF (Windows Communication Foundation)

WCF (Windows Communication Foundation) is a framework API/set that unifies various distributed architectural models and technologies under a single umbrella, providing a rich set of built-in components for developing distributed applications based on a service-oriented architecture (SOA). Introduced by Microsoft as an alternative to Web Services.

In response to Microsoft’s requirements, the company has developed numerous systems using a fragmented architectural approach—such as “XML Web Services,” “COM+,” ”.NET Remoting,” and “MSMQ”—and has consolidated the strengths of these services into WCF.

WCF architecture is used for developing systems that facilitate message transmission between clients and services. These messages can be sent over intranets and the Internet using common transport protocols such as TCP, HTTP, MSMQ, Web Services, and others. .NET Remoting, XML Web Services, Web Service Enhancements (WSE), Enterprise Services/COM+, and Microsoft Message Queue (MSMQ) are all provided to developers as a unified programming model for various distributed application development models.

We can state that WCF is designed for developing SOAP (Simple Object Access Protocol)-based services. SOAP is a web protocol that uses XML and HTTP for data description and data transfer. When compared to SOAP REST, which uses XML schemas over HTTP, SOAP is generally slower and more restrictive.

  • When using XML and HTTP for web service data description and data transfer, WCF uses SOAP/XML.
  • WCF is considered by Microsoft to be a more efficient and effective alternative to web services.

.NET 3.5 supports SOA. Initially, object-oriented programming (OOP) is used, followed by component-oriented programming, and finally, SOA is incorporated. “WCF” effectively utilizes SOA. In addition to SOA, WCF is platform-independent. As a result, applications running on any operating system can operate in different environments.

Service-Oriented Architecture (SOA)

Service-Oriented Architecture (SOA) is a software design style used for developing loosely coupled, coarse-grained, and autonomous distributed systems based on components. Application components communicate with each other through a network communication protocol. In a service-oriented architecture, vendors, products, and technologies are independent of one another.

Within SOA, there are two primary roles:

  • Service provider enables the availability of one or more services and other access points, and provides the organization’s structure.
  • Service consumer registers service metadata in a registry and develops client components required to integrate/use the service.

API, WEB API and WEB Service

API (Application Programming Interface) was previously described in detail, defining API as “an interface that enables an application/service to use the capabilities available on a platform, within defined boundaries including external access and authorized restrictions”. Thus, we can state that the API operates within a general context.

API and Web Service
API and Web Service

API and Web Service are used as communication intermediaries. An API does not have to be web-based at all times. An API must follow rules governing interaction. A Web Service, however, is not required to follow all such rules.

  • A Web Service is an API, but every API is not a Web Service.
  • A Web Service may not be able to perform the operations required by an API.
  • Web Services use SOAP, REST, or XML-RPC styles.
  • A Web Service always requires a network for operation; an API does not have such a requirement.

Additionally,

  • Web Services are XML-based within the standard framework defined by W3C and generally facilitate machine-to-machine communication.
  • Web API can be used to create REST services and requires no configuration at the WCF level.
  • Web API can accept input in XML/JSON or plain data, and output in JSON/XML.

WEB API is simpler and more flexible compared to Web Services and WCF. It can return responses in many formats, including XML. On the other hand, WCF is the most suitable choice for scenarios such as duplex (full-duplex) communication, end-to-end message security, one-way messaging, and distributed transactions. WEB API is preferable for creating resource-oriented services using HTTP/RESTful principles. It works well with MVC-based applications.

Today, it can be said that a shift toward WEB API/REST is taking place in web projects due to their flexibility and practicality.

Microservice Architecture

Microservices (Microservices) or Microservice Architecture (Microservice Architecture) are small, independent services that work together. It represents a new approach to software modularization and software development architecture. They can communicate with each other to perform a task within a much larger application. A Web Service is not tied to any particular operating system or programming language and uses a standard XML messaging system. Changes or errors in one of the created services do not affect other services.

Martin Fowler and James Lewis define the microservice architecture as follows1: “…a microservice architecture style is an application development approach that consists of a series of small services, each running in its own process and communicating through a structure similar to an HTTP resource API. These services are built around business capabilities and can be independently operated, deployed, and managed. They can be written in different programming languages and utilize different data storage technologies, with minimal centralized management.

Both microservices and web services are application architectures used for developing and deploying software applications. However, their development styles differ. Microservices follow a development architecture structured as a collection of related modules. They can also be described as a simplified service-oriented architecture (SOA). Web services, on the other hand, are interfaces accessible over a network, enabling one application to access the functions of another application. A web service is accessed over a network via a combination of protocols such as HTTP, XML, SMTP, or Jabber. Microservices can be included within a web service. However, microservices can be any service that operates as an independent, standalone function with its own database, and can be deployed independently of one another, using different technologies.

A web service functions as an abstraction layer that separates platform- and programming language-specific details regarding how application code is invoked. This represents an API that operates via HTTP. It is a service that enables another application to communicate with one another over the World Wide Web using XML messages.

Monolith and Microservice Architecture
Monolith and Microservice Architecture

Monolith Architecture

Large-scale applications composed of a single, monolithic structure that contains all features and functions.

Compared to microservices:

  • The application size is large,
  • The release cycle is long,
  • Debugging problems and testing processes are highly cumbersome,
  • A large development team is required,
  • In the event of any issue or change, the application and any service it provides become inaccessible.

Microservices can provide convenience for the above processes and can support various technologies. Due to their independence and self-sufficiency, they can be integrated into many applications (pipes, UNIX sockets, messaging, email, etc.). A microservice is designed to perform a single task exceptionally well and effectively. However, as the number of services increases, the orchestration process can easily lose control. At this point, the DevOps concept comes into play. Microservices do not have to be RESTful, nor do they necessarily need to have access to a database and/or an API. A web service can be a microservice, but a microservice does not have to be a web service. In short, microservices can be described as mini applications that communicate with each other. Web services are also mini applications, but they communicate through the network using predefined formats.

Difference Between
Quora
Scalyr

Others

Monolith Architecture

*[SOA]: Service-Oriented Architecture

Footnotes

  1. James Lewis, Martin Fowler. (2014). Microservices