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…
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.
flowchart TBPortal --> ESB[Enterprise Service Bus]ESB --> CRMESB --> BillingESB --> Inventory
Internal architecture
Architecture overview
flowchart TBPortal --> ESB[Enterprise Service Bus]ESB --> CRMESB --> BillingESB --> Inventory
Step-by-step explanation
- Channel apps (portal, mobile) call API layer or ESB entry point.
- ESB handles authentication, schema transformation, routing to backend systems.
- Legacy adapters wrap mainframe COBOL or SAP modules as SOAP/REST services.
- Business process orchestration (BPEL) coordinates multi-step workflows centrally.
- Shared enterprise data models (canonical customer ID) reduce duplication.
- 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:
@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());}}@Componentpublic class LegacyBillingGateway {public SoapBalanceResult fetchBalance(String accountId) {// SOAP/XML call to ESB-routed mainframe adapterreturn 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
Interview Prep
Practice concise answers, then expand each card for the explanation.
1BeginnerQuestionWhat is SOA?+
Answer
2BeginnerQuestionHow does SOA differ from microservices?+
Answer
3IntermediateQuestionRole of an ESB?+
Answer
4IntermediateQuestionWhen keep an ESB vs API gateway?+
Answer
5AdvancedQuestionModernize bank SOA to cloud?+
Answer
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.