Service-Oriented Architecture (SOA) in System Design
Service-Oriented Architecture (SOA) is a way of building software as a collection of reusable services that communicate over a network through well-defined contracts. Instead of each application containing its own copy of features such as customer lookup, payments or notifications, those features are offered once as shared services that many applications can use.
This tutorial explains why SOA was created, its core principles, its building blocks such as the service registry and the Enterprise Service Bus (ESB), the main types of services, how SOAP and REST services are built in Java, and how SOA compares with monoliths and microservices. It ends with advantages, drawbacks and guidance on when SOA still makes sense today.
1. What Is Service-Oriented Architecture?
Imagine a banking platform where customer onboarding, account management, statement generation, and notification delivery are implemented as separate services. Each service is responsible for a specific business capability and communicates with other services through well-defined APIs. This architectural approach is known as Service-Oriented Architecture (SOA).
SOA promotes the idea of building software as a collection of loosely coupled services that expose business capabilities through standard contracts. Services hide their implementation behind those contracts and are designed for reuse across many applications. In practice, SOA services are often coarse-grained, may share enterprise databases and are frequently connected through an enterprise service bus, which is one of the main differences from microservices.
2. Why SOA Was Created
Large companies typically run dozens of systems bought or built over many years: a CRM for customers, an ERP for finance, a warehouse system, an HR system and more. Each was built with different technology, and each kept its own copy of shared data such as customer details.
When these systems needed to talk to each other, teams built custom point-to-point integrations between each pair. With a handful of systems, the number of connections exploded, every change broke something, and the same logic was duplicated everywhere.
SOA addressed these problems by:
- Reusing business functions as shared services instead of duplicating them.
- Standardising how systems communicate, using common protocols and message formats.
- Decoupling systems so one can be replaced without rewriting all the others.
- Aligning IT with business processes, so a process like "open a bank account" is modelled as a composition of services.
3. Core Principles of SOA
| Principle | Meaning | Example |
|---|---|---|
| Standardised service contract | Every service publishes a formal description of its operations and data | A WSDL or OpenAPI document for the Customer Service |
| Loose coupling | Consumers depend only on the contract, not on internal details | Billing can change its database without breaking callers |
| Abstraction | Services hide their internal logic and technology | Callers do not know the Credit Service runs on a mainframe |
| Reusability | Services are designed to be used by many processes | One Notification Service used by sales, HR and support |
| Autonomy | Each service controls its own logic and resources | The Inventory Service owns stock data and rules |
| Statelessness | Services avoid keeping client-specific state between calls | Each request carries everything needed to process it |
| Discoverability | Services can be found and understood through a registry | Developers search the registry for an "Address Validation" service |
| Composability | Services can be combined into larger services and processes | A "Loan Application" process composed of credit, customer and document services |
4. Components of SOA
A classic SOA has three roles connected in a triangle, plus supporting infrastructure:
- Service provider: implements the service and publishes its contract.
- Service consumer: any application or service that calls a service.
- Service registry/repository: a catalogue of available services, their contracts, versions and owners. Historically UDDI registries; today often an API catalogue or developer portal.
- Service contract: the formal interface, traditionally a WSDL file for SOAP services, or an OpenAPI document for REST services.
- Enterprise Service Bus (ESB): middleware that connects services, routes and transforms messages and applies shared policies (explained next).
- Governance: the rules and processes for designing, versioning, securing and retiring services across the organisation.
5. The Enterprise Service Bus (ESB)
The ESB is the communication backbone of many SOA implementations. Rather than calling each other directly, services send messages through the bus, which provides:
- Routing: deciding which service receives a message, for example based on its content.
- Transformation: converting between formats, such as XML from an old system to the format a newer service expects.
- Protocol mediation: letting a service that speaks SOAP over HTTP talk to one that reads from a JMS queue or a file drop.
- Orchestration: running multi-step business processes that call several services in order.
- Cross-cutting policies: security, logging, monitoring and reliable delivery in one place.
Well-known ESB products include MuleSoft, IBM Integration Bus (App Connect), Oracle Service Bus, WSO2, and open-source integration frameworks such as Apache Camel and Apache ServiceMix.
The ESB is also SOA's biggest weakness. When too much business logic moves into the bus, it becomes a central, complex component that every team depends on, a bottleneck for changes and a single point of failure. This "smart pipes" problem is one of the main reasons the microservices movement later preferred "smart endpoints and dumb pipes".
6. How SOA Works: A Loan Application Example
A bank wants to let customers apply for loans through a web portal. In an SOA design, the process is built from existing shared services:
- The customer submits an application on the portal.
- The Loan Application process service asks the Customer Service for the customer's verified details.
- It calls the Credit Check Service, which in turn talks to an external credit bureau.
- It stores the uploaded salary slips through the Document Service.
- Based on the credit score, it approves or rejects the loan and asks the Notification Service to email the customer.
The key benefit is reuse. The Customer Service is also used by the account-opening process, the Credit Check Service by the credit card process, and the Notification Service by almost everything. Each service is built once and maintained by one team.
7. Types of Services in SOA
| Service type | Purpose | Examples |
|---|---|---|
| Entity services | Manage a core business entity and its data | Customer Service, Product Service, Account Service |
| Business (task) services | Perform a specific business task, often using entity services | Credit Check, Price Calculation, Fraud Screening |
| Process (orchestration) services | Coordinate several services to complete an end-to-end business process | Loan Application, Order Fulfilment, Employee Onboarding |
| Utility (infrastructure) services | Provide technical capabilities that are not tied to one business area | Notification, Logging, Document Storage, Authentication |
| Partner services | Expose functionality to, or consume it from, external organisations | Payment gateway, shipping carrier, credit bureau integrations |
8. SOAP Web Services and WSDL
Many SOA systems use SOAP (originally "Simple Object Access Protocol"), an XML-based messaging protocol. Every message is an XML envelope with an optional header (for security tokens, transaction IDs and so on) and a body containing the actual request or response. The service's operations and data types are described in a WSDL (Web Services Description Language) file, from which client code can be generated automatically.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cr="http://javabytechie.com/credit">
<soap:Header/>
<soap:Body>
<cr:checkCredit>
<customerId>C-1042</customerId>
<loanAmount>500000</loanAmount>
</cr:checkCredit>
</soap:Body>
</soap:Envelope>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cr="http://javabytechie.com/credit">
<soap:Body>
<cr:checkCreditResponse>
<score>742</score>
<decision>APPROVED</decision>
</cr:checkCreditResponse>
</soap:Body>
</soap:Envelope>
SOAP comes with a family of WS-* standards for security (WS-Security), reliable messaging and transactions, which is why it remains common in banking, insurance, telecoms and government integrations. Its downsides are verbose XML and heavier tooling. SOA itself does not require SOAP; many modern service-oriented systems use REST with JSON and OpenAPI contracts instead.
9. Building a SOAP Service in Java
Jakarta XML Web Services (JAX-WS) lets you turn a plain Java class into a SOAP service with annotations. Since Java 11, the implementation is a separate dependency, such as com.sun.xml.ws:jaxws-rt.
package com.javabytechie.soa;
import jakarta.jws.WebMethod;
import jakarta.jws.WebParam;
import jakarta.jws.WebService;
@WebService(serviceName = "CreditCheckService", targetNamespace = "http://javabytechie.com/credit")
public class CreditCheckService {
@WebMethod
public CreditResult checkCredit(@WebParam(name = "customerId") String customerId,
@WebParam(name = "loanAmount") long loanAmount) {
int score = lookUpScore(customerId);
String decision = (score >= 700 && loanAmount <= 1_000_000) ? "APPROVED" : "REVIEW";
return new CreditResult(score, decision);
}
private int lookUpScore(String customerId) {
// In a real system this would call the credit bureau
return customerId.endsWith("2") ? 742 : 655;
}
}
package com.javabytechie.soa;
public class CreditResult {
private int score;
private String decision;
public CreditResult() { } // required by JAXB for XML mapping
public CreditResult(int score, String decision) {
this.score = score;
this.decision = decision;
}
public int getScore() { return score; }
public void setScore(int score) { this.score = score; }
public String getDecision() { return decision; }
public void setDecision(String decision) { this.decision = decision; }
}
package com.javabytechie.soa;
import jakarta.xml.ws.Endpoint;
public class CreditServicePublisher {
public static void main(String[] args) {
String address = "http://localhost:8085/credit";
Endpoint.publish(address, new CreditCheckService());
System.out.println("Credit Check Service running. WSDL: " + address + "?wsdl");
}
}
Credit Check Service running. WSDL: http://localhost:8085/credit?wsdl
Opening the WSDL URL shows the generated contract. Any consumer, written in Java, C#, Python or another language, can generate a client from it. In Spring applications, Spring Web Services offers a contract-first alternative where you write the XML schema first and generate Java classes from it.
10. Composing REST Services in Java
Modern service-oriented systems often use REST and JSON. The process service below composes three shared services into the loan workflow using Spring's RestClient:
package com.javabytechie.soa;
import java.math.BigDecimal;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClient;
@Service
public class LoanApplicationService {
public record LoanRequest(String customerId, BigDecimal amount) { }
public record Customer(String id, String name, String email) { }
public record CreditCheckRequest(String customerId, BigDecimal amount) { }
public record CreditReport(int score) { }
public record Notification(String to, String message) { }
public record LoanDecision(boolean approved, String message) { }
private final RestClient customerService;
private final RestClient creditService;
private final RestClient notificationService;
public LoanApplicationService(RestClient.Builder builder) {
this.customerService = builder.clone().baseUrl("http://customer-service/api").build();
this.creditService = builder.clone().baseUrl("http://credit-service/api").build();
this.notificationService = builder.clone().baseUrl("http://notification-service/api").build();
}
public LoanDecision apply(LoanRequest request) {
Customer customer = customerService.get()
.uri("/customers/{id}", request.customerId())
.retrieve()
.body(Customer.class);
CreditReport report = creditService.post()
.uri("/credit-checks")
.body(new CreditCheckRequest(customer.id(), request.amount()))
.retrieve()
.body(CreditReport.class);
LoanDecision decision = report.score() >= 700
? new LoanDecision(true, "Dear " + customer.name() + ", your loan is approved.")
: new LoanDecision(false, "Dear " + customer.name() + ", your application needs review.");
notificationService.post()
.uri("/notifications")
.body(new Notification(customer.email(), decision.message()))
.retrieve()
.toBodilessEntity();
return decision;
}
}
Each called service is owned by a different team and reused elsewhere. The process service knows only their contracts. In production you would add timeouts, retries, circuit breakers and security tokens to these calls.
11. Monolith vs SOA vs Microservices
SOA sits between a single monolithic application and fine-grained microservices. Microservices are often described as an evolution of SOA ideas, with smaller services and lighter communication.
| Aspect | Monolith | SOA | Microservices |
|---|---|---|---|
| Scope | One application | Integration across the whole enterprise | One application split into small services |
| Service size | Not applicable | Coarse-grained, broad business functions | Fine-grained, one business capability each |
| Communication | In-process method calls | Often through an ESB; SOAP, JMS, also REST | Direct lightweight calls (REST, gRPC) and event streams |
| Logic in the middleware | None | Often significant ("smart pipes") | Minimal ("dumb pipes, smart endpoints") |
| Data | One shared database | Often shared enterprise databases | Each service owns its own data |
| Main goal | Simplicity | Reuse and integration of existing systems | Independent deployment and scaling, team autonomy |
| Deployment | Deploy everything together | Services deployed separately, but often coordinated | Each service deployed independently, many times a day |
| Governance | Single team | Centralised, enterprise-wide standards | Decentralised, each team chooses within guidelines |
| Typical setting | Startups, small applications | Large enterprises with many legacy systems | Cloud-native products with many teams |
See Monolithic vs Microservices Architecture for more on the other two styles.
12. Advantages of SOA
- Reusability: a service built once is used by many applications, reducing duplicate code and cost.
- Easier integration: standard contracts let very different systems, including legacy mainframes and packaged software, work together.
- Loose coupling: services can be modified or replaced behind a stable contract.
- Technology independence: each service can use the platform that suits it best.
- Business alignment: services map to business capabilities, making processes easier to understand and change.
- Parallel development: different teams can build different services at the same time.
- Centralised policies: security, auditing and monitoring can be enforced consistently, often in the ESB.
13. Disadvantages of SOA
- Complex middleware: ESBs and governance tools are expensive and need specialised skills.
- ESB bottleneck: putting too much logic in the bus creates a central component that slows every change and can fail for everyone.
- Performance overhead: network calls, XML processing and message transformation add latency.
- Heavy governance: enterprise-wide standards and approval processes can slow teams down.
- Shared data coupling: services sharing large enterprise databases are harder to change independently.
- Upfront investment: designing reusable services requires significant analysis before benefits appear.
14. When to Use SOA Today
SOA is still a good fit when:
- You must integrate many existing systems, such as ERP, CRM, mainframes and partner systems, that cannot be rewritten.
- You work in a regulated industry (banking, insurance, healthcare, government) where SOAP and WS-Security are expected by partners.
- Many applications need the same business capabilities, and central reuse is more valuable than independent speed.
- The organisation already has integration middleware and skills in place.
For new cloud-native products built by autonomous teams, microservices or a well-structured modular monolith are usually better starting points. Many large organisations run a hybrid: SOA-style integration for core and legacy systems, with microservices for new customer-facing products.
15. Best Practices
- Design services around business capabilities, not database tables or technical layers.
- Write contracts first and treat them as public APIs: version them and avoid breaking changes.
- Keep the ESB focused on routing, transformation and protocol bridging; keep business rules inside services.
- Make services stateless and idempotent where possible, so retries are safe.
- Maintain a searchable service catalogue with owners, documentation and versions.
- Secure every service call with authentication, authorisation and encryption.
- Monitor each service and trace requests across service calls with correlation IDs.
- Keep governance lightweight enough that it guides teams without blocking them.
16. Summary
- SOA builds systems from reusable, network-accessible services with standard contracts.
- Its core principles are standard contracts, loose coupling, abstraction, reuse, autonomy, statelessness, discoverability and composability.
- Key components are service providers, consumers, a registry and often an Enterprise Service Bus for routing, transformation and orchestration.
- Services can be built with SOAP and WSDL or with REST and OpenAPI; SOA is an architectural style, not a single technology.
- Compared with microservices, SOA uses larger services, more central governance and smarter middleware, and focuses on enterprise-wide reuse and integration.
Understanding SOA explains where many microservices ideas came from and why certain trade-offs were made. Open the Interview Questions tab for interview questions and answers about Service-Oriented Architecture.
Service-Oriented Architecture: Interview Questions and Answers
The questions on this topic that come up most often in system design interviews for senior engineers, tech leads and architects. Each answer covers the reasoning, trade-offs and real-world examples that interviewers look for.
Q1. How does SOA differ from microservices?
Both build systems from services, but with different scope and governance. Classic SOA (mid-2000s) aimed at enterprise-wide reuse and integration: larger services shared across many applications, often communicating through an enterprise service bus (ESB) with SOAP/WSDL, central governance and sometimes shared databases. Microservices aim at independent delivery by small teams: fine-grained services aligned with bounded contexts, each owning its data, using lightweight protocols (REST, gRPC, messaging) and "smart endpoints, dumb pipes" instead of a central bus.
Q2. What is an enterprise service bus, and why did it fall out of favour?
An ESB is middleware that connects services and handles routing, transformation, protocol mediation and orchestration centrally. It simplified integrating heterogeneous legacy systems, but business logic and mappings accumulated in the bus, making it a bottleneck for change, owned by a central team, and a single point of failure. Modern systems prefer lightweight brokers (Kafka, RabbitMQ) with logic in the services, plus API gateways at the edge.
Q3. Is SOA still relevant today?
Yes, in large enterprises integrating many existing systems (ERP, CRM, mainframes), banks and governments with SOAP-based contracts, and anywhere reuse of shared enterprise services matters more than team autonomy. Its principles (loose coupling, explicit contracts, service reuse, discoverability) live on in microservices and API-first design. Interviewers often want you to explain the evolution and when the older approach is still reasonable.
Q4. What does "service contract" mean, and why is it central to SOA?
A contract is the formal definition of what a service offers: operations, message formats, error behaviour, and often policies such as security and SLAs. In SOAP it is a WSDL with XML schemas; today it is often an OpenAPI or gRPC/Protobuf definition. Contracts let consumers integrate without knowing the implementation, and they must be versioned and evolved compatibly because many consumers depend on them.
Q5. How would you modernise a legacy SOA system with an ESB?
Incrementally. Put an API gateway in front for new consumers, identify integrations in the ESB that change often or are business-critical, and move them into owning services with direct APIs or events. Introduce event streaming for data that many systems need, use the strangler fig pattern to retire ESB flows one at a time, and keep stable legacy integrations on the bus until replacing them pays off.
Q6. What are the main governance trade-offs between SOA and microservices?
SOA favoured central governance: shared standards, canonical data models and a service registry, which gives consistency and reuse but slows change. Microservices favour decentralised governance: teams choose within guard rails and own their services, which speeds delivery but risks duplication and inconsistency. Most organisations land in between, with platform standards for security, observability and API style, and freedom inside service boundaries.