Compiling multiple wdsl files into a single client #89
Replies: 1 comment
|
Short answer: the generator is intentionally single-WSDL, and in most cases composing separate generated clients is the better long-term choice than merging. But "which WSDLs, and why combine them" changes the recommendation, so let me lay out the paths. Quick diagnosticA few questions, with the path each answer points to:
Path A — Same upstream, split across WSDLsIf the WSDLs are really one logical service whose schema is split (common with vendors that modularise xsds), the right fix is upstream, not in the CLI. Author a top-level WSDL that xs:imports the others and point --wsdl-source at that. The loader already follows xs:import / xs:include transitively, and the compiler resolves cross-namespace references. This gives you a single client with zero changes to the generator. Path B — Independent services, you just want one install / one HTTP surfaceThis is the most common case, and composition at the app layer handles it cleanly. Generate one client per WSDL (what you're doing now) and wire them together: // services.ts export const services = { If you also want a single HTTP surface, mount both generated Fastify gateways under different prefixes in one app: await app.register(gatewayA, { prefix: "/services/a" }); Keeps independent regeneration, independent versioning, failure isolation per service, and avoids every collision problem. Path C — You want a unified public API (one package, one typed entry point)Wrap the generated clients in a small facade package that re-exports them under namespaces: // index.ts Consumers write A.User vs B.User and get full type safety with no collisions. You own the facade, so breaking changes in one upstream don't ripple into the other's types. Path D — You genuinely need one merged client (not recommended)Worth being explicit about why the generator doesn't do this today:
Making the generator do this properly means namespace-prefixing every generated identifier (ServiceA_User, ServiceB_User), teaching the client to pick endpoints per operation, and emitting an OpenAPI doc with per-operation servers. The resulting code is strictly less ergonomic than Path C for consumers, and it couples the services' release cycles. I'd only pursue this if you're locked into a single endpoint for transport reasons (e.g. one gateway in front of both) and the WSDLs are guaranteed not to collide — and even then, a thin wrapper is almost always simpler. RecommendationIf you tell me which of the four situations matches yours (and whether there are name overlaps), I can sketch the concrete wiring. My prior is that most people asking this question are in Path B or C, and the answer is "keep the separate clients, add a small composition layer." Path A only if the WSDLs belong together upstream, Path D almost never. |
Uh oh!
There was an error while loading. Please reload this page.
We have a couple of wdsl files and right now we're building each into a separate client. Is there a way to compile multiple wsdl into the one client?
All reactions