Skip to content
Tutorials Center
My learning

Topics

Lesson 31 of 36 ยท Migration and Integration

Integration Patterns: ESBs, Gateways and Message Translation

Learn the integration patterns behind SOAP landscapes - gateways, ESBs, canonical models, content-based routing, message translation and asynchronous request-reply with WS-Addressing correlation, with runnable examples.

Few SOAP services live alone. A typical company has an order system, a billing system, a warehouse, a CRM and a handful of partners, built in different decades with different formats. Integration is the work of making them exchange messages reliably, and a small set of recurring patterns (catalogued in the book Enterprise Integration Patterns) covers most of it.

This lesson introduces the patterns you will meet around SOAP services: the gateway and the Enterprise Service Bus, the canonical data model, the translator, the router, and asynchronous request-reply. Two of them are implemented below so you can see how little code the core idea needs.

Gateways and the ESB

An API gateway sits in front of services and handles cross-cutting concerns once: authentication, rate limits, logging, TLS, request size limits, sometimes translation between SOAP and REST. Clients talk to one address.

An Enterprise Service Bus (ESB) was the classic 2000s answer to integration. It is a central runtime (products like MuleSoft, IBM Integration Bus, WSO2, Oracle Service Bus, TIBCO, and the open-source Apache Camel and ServiceMix) that receives messages, transforms and routes them, and talks many protocols. Its strength is one place to see and manage flows. Its weakness, when overused, is that all business logic ends up in a central, hard-to-test box that every team depends on. Modern designs prefer smart endpoints and dumb pipes: keep logic in the services, use the integration layer for routing and translation only.

flowchart LR
  A["Partner A (SOAP/XML)"] --> T1["Translator A"]
  B["Partner B (REST/JSON)"] --> T2["Translator B"]
  T1 --> R["Router"]
  T2 --> R
  R --> W1["Warehouse EU"]
  R --> W2["Warehouse US"]

Each partner gets one translator into a shared format; the router needs to know only that format.

The canonical data model

If you have N systems with N different formats, direct translation between each pair needs N x (N-1) translators. A canonical model is one agreed internal format. Each system needs only two translators (to and from canonical), so the number grows linearly. The cost is that you must design and maintain the canonical model carefully, and keep it small.

Translator and router in code

Partner A sends a SOAP order; partner B sends JSON. Both are translated into one canonical object, and a content-based router then picks a destination from the content (the shipping country).

Node.js Translators, a canonical model and a router

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Adding a third partner means writing one translator. Adding a warehouse means adding one routing rule. Neither change touches the other partners, which is the whole point.

Asynchronous request-reply and correlation

Not every SOAP call is answered immediately. A long-running credit check might accept the request, return "received", and send the result later to a callback URL or a queue. For this to work, each reply must be correlated with its request. The WS-Addressing standard defines SOAP headers for this: MessageID on the request, ReplyTo for where to send the answer, and RelatesTo on the reply carrying the original MessageID.

Node.js Correlating replies with MessageID / RelatesTo

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Several requests in flight at once, and every reply finds the right waiter, because the RelatesTo header carries the identifier, not the arrival order. Note the time-out path: a request that never gets its reply must fail cleanly and free its entry. The second "ignored reply" line at the end is the late answer to that timed-out request arriving after nobody waits for it any more, which is the right thing to ignore.

Other patterns worth knowing

  • Message filter and splitter/aggregator: drop irrelevant messages; split a batch into single messages and collect results afterwards.
  • Dead letter queue: park messages that repeatedly fail so one bad message does not block the stream.
  • Idempotent receiver: recognize duplicates, which delivery guarantees like "at least once" will eventually produce.
  • Claim check: keep large payloads (documents, images) in storage and pass a reference, which is what MTOM attachments solve for SOAP.
  • Circuit breaker: stop calling a failing service for a while so it can recover and your threads are not exhausted.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why use a canonical data model?

    With N systems, pairwise translation grows quadratically; a canonical model keeps it linear.
  2. 2. What does a content-based router use to choose a destination?

    The router inspects the message content and applies rules to pick the next hop.
  3. 3. In WS-Addressing, which header on a reply carries the id of the original request?

    RelatesTo holds the MessageID of the message being answered, which allows correlation.
  4. 4. What is a common criticism of overusing an ESB?

    Keep the bus for routing and translation; leave business rules in the owning services.

Summary

  • Gateways centralize cross-cutting concerns; ESBs centralize routing and translation, but should not own business logic.
  • A canonical model with one translator per system keeps integration linear in size.
  • Content-based routers choose destinations from message data.
  • Asynchronous replies are matched with MessageID / RelatesTo, and every pending request needs a time-out.
  • Dead letter queues, idempotent receivers, claim check and circuit breakers make integrations robust.

Next: Versioning and Evolving Legacy SOAP Services