High-Level Design Tutorial 0/42 lessons ~6 min read Lesson 7

    Service-Oriented Architecture (SOA)

    Service-Oriented Architecture (SOA) organizes enterprise systems as coarse-grained, reusable services exposed through standardized interfaces — historically SOAP over an Enterpr…

    Course progress0%
    Focus
    10 guided sections
    Practice signal
    Examples included
    Career prep
    Interview Q&A included

    Introduction

    Service-Oriented Architecture (SOA) organizes enterprise systems as coarse-grained, reusable services exposed through standardized interfaces — historically SOAP over an Enterprise Service Bus (ESB). SOA predates microservices and emphasizes integration across legacy ERP, CRM, and billing systems rather than greenfield cloud-native apps.

    In modern HLD interviews, SOA appears when discussing banks, insurance, or enterprises with decades of mainframe and Java EE assets. Understanding SOA helps you contrast ESB orchestration vs microservice choreography and explain why many firms run hybrid landscapes.

    This lesson maps SOA concepts to today's API-led integration and when an ESB still makes sense.

    Understanding the topic

    Key concepts

    • Coarse-grained business services: CustomerService, BillingService, InventoryService.
    • ESB: central hub for routing, transformation, protocol bridging (SOAP ↔ REST).
    • Service registry and contract-first WSDL/OpenAPI definitions.
    • Reusability across channels: web, mobile, partner B2B, branch terminals.
    • Heavier governance than microservices — enterprise architecture review boards.
    • Microservices are SOA evolution: smaller services, lighter protocols, no single ESB bottleneck.
    text
    flowchart TB
    Portal --> ESB[Enterprise Service Bus]
    ESB --> CRM
    ESB --> Billing
    ESB --> Inventory

    Internal architecture

    Architecture overview

    text
    flowchart TB
    Portal --> ESB[Enterprise Service Bus]
    ESB --> CRM
    ESB --> Billing
    ESB --> Inventory

    Step-by-step explanation

    1. Channel apps (portal, mobile) call API layer or ESB entry point.
    2. ESB handles authentication, schema transformation, routing to backend systems.
    3. Legacy adapters wrap mainframe COBOL or SAP modules as SOAP/REST services.
    4. Business process orchestration (BPEL) coordinates multi-step workflows centrally.
    5. Shared enterprise data models (canonical customer ID) reduce duplication.
    6. Modern variant: API gateway + iPaaS replaces monolithic ESB for new integrations.

    Informative example

    Modern SOA-style integration: Spring Integration adapter exposing legacy billing to REST consumers:

    java
    @RestController
    @RequestMapping("/api/v1/billing")
    public class BillingFacadeController {
    private final LegacyBillingGateway legacy;
    public BillingFacadeController(LegacyBillingGateway legacy) {
    this.legacy = legacy;
    }
    @GetMapping("/accounts/{id}/balance")
    public BalanceResponse balance(@PathVariable String id) {
    SoapBalanceResult soap = legacy.fetchBalance(id);
    return new BalanceResponse(id, soap.amount(), soap.currency(), Instant.now());
    }
    }
    @Component
    public class LegacyBillingGateway {
    public SoapBalanceResult fetchBalance(String accountId) {
    // SOAP/XML call to ESB-routed mainframe adapter
    return new SoapBalanceResult(new BigDecimal("1250.00"), "USD");
    }
    }

    In enterprise HLD, emphasize anti-corruption layers between canonical REST APIs and legacy SOAP backends.

    Real-world use

    Real-world use cases

    • Banking cores integrating card, loan, and CRM systems via ESB.
    • Insurance policy administration spanning mainframe rating engines.
    • Retail ERP connecting warehouse, POS, and e-commerce catalog.
    • Government portals aggregating citizen data from siloed departments.

    Best practices

    • Prefer API gateway + dedicated adapters over one overloaded ESB.
    • Document canonical data models and versioning for shared services.
    • Isolate legacy protocols behind facades — don't leak SOAP shapes to mobile clients.
    • Monitor ESB latency — central hubs become single points of congestion.
    • Gradually strangler-replace ESB routes with direct event-driven links.
    • Align service granularity with business capabilities, not vendor packages.

    Common mistakes

    • Treating ESB as a database — storing state in message headers improperly.
    • Creating omnibus 'God service' on the bus with all business logic.
    • Ignoring idempotency on asynchronous SOA messages.
    • Confusing SOA with microservices — different granularity and governance.
    • Protocol translation without schema validation — silent data corruption.

    Advanced interview questions

    Q1BeginnerWhat is SOA?
    Architecture exposing coarse-grained reusable business services through standardized interfaces, often via an ESB.
    Q2BeginnerHow does SOA differ from microservices?
    SOA uses larger services, heavier protocols, central ESB orchestration; microservices favor small services, REST/events, decentralized choreography.
    Q3IntermediateRole of an ESB?
    Message routing, protocol transformation, mediation between producers and consumers in enterprise integration.
    Q4IntermediateWhen keep an ESB vs API gateway?
    ESB when many legacy protocol bridges and central orchestration exist; gateway for cloud-native REST edge and lightweight routing.
    Q5AdvancedModernize bank SOA to cloud?
    API gateway for channels, event backbone for async, strangler adapters off ESB, retain canonical models, PCI isolate payment — phased not big-bang.

    Summary

    SOA focuses on enterprise integration and reusable business services. ESB centralizes routing; watch for bottleneck and governance drag. Microservices evolved from SOA with smaller units and lighter stacks. Use anti-corruption layers for legacy backends. Hybrid landscapes are normal in banking and insurance HLD. Event-driven architecture reduces ESB centrality over time.

    Ready to mark this lesson complete?Track your journey across the entire course.