Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
generateClient
✓ import { generateClient } from 'wsdl-tsclient';
✗ const { generateClient } = require('wsdl-tsclient');
While CommonJS `require` might work in some Node.js environments due to `esModuleInterop` in `tsconfig.json`, explicit ESM `import` is the recommended and modern approach for this TypeScript-first library.
createClientAsync
✓ import { createClientAsync } from './generated/MyWsdl';
✗ const { createClientAsync } = require('./generated/MyWsdl');
This import is for the *generated* client code. If you use the `--esm` CLI flag (available since v1.7.1) for generation, the output imports will include `.js` suffixes. Without it, standard ESM imports are assumed. The `wrong` example shows CommonJS which would fail if the generated code is truly ESM.
MyServicePort
✓ import { IMyServicePort } from './generated/MyWsdl/MyServicePort';
This is an example of importing a generated TypeScript interface for a specific service port, often used for type-checking or mocking. The exact path depends on the WSDL structure and generated file names. The generated files are typically TypeScript and best consumed via `import`.
This example demonstrates how to programmatically generate a TypeScript SOAP client from a WSDL file and then use the generated client to make a call to a (mocked) SOAP service. It includes setup for a dummy WSDL and output directory.
import { generateClient } from 'wsdl-tsclient';
import { createClientAsync } from './generated/MyService'; // This path will vary based on your WSDL
import * as path from 'path';
import * as fs from 'fs';
async function runGenerationAndClient() {
const wsdlPath = path.resolve(__dirname, 'resources', 'MyService.wsdl');
const outputPath = path.resolve(__dirname, 'generated');
// Ensure output directory exists
if (!fs.existsSync(outputPath)) {
fs.mkdirSync(outputPath, { recursive: true });
}
// Placeholder WSDL content for demonstration
// In a real scenario, you'd have a physical WSDL file.
const dummyWsdlContent = `<?xml version="1.0" encoding="UTF-8"?>
<definitions name="MyService" targetNamespace="http://www.example.org/MyService/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<types>
<xsd:schema targetNamespace="http://www.example.org/MyService/">
<xsd:element name="SayHelloRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="SayHelloResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="greeting" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<message name="SayHelloRequest">
<part name="parameters" element="tns:SayHelloRequest"/>
</message>
<message name="SayHelloResponse">
<part name="parameters" element="tns:SayHelloResponse"/>
</message>
<portType name="MyService">
<operation name="SayHello">
<input message="tns:SayHelloRequest"/>
<output message="tns:SayHelloResponse"/>
</operation>
</portType>
<binding name="MyServiceSOAP" type="tns:MyService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="SayHello">
<soap:operation soapAction="http://www.example.org/MyService/SayHello"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="MyService">
<port name="MyServiceSOAP" binding="tns:MyServiceSOAP">
<soap:address location="http://localhost:8000/MyService"/>
</port>
</service>
</definitions>`;
// Save dummy WSDL for generation
const resourcesDir = path.resolve(__dirname, 'resources');
if (!fs.existsSync(resourcesDir)) {
fs.mkdirSync(resourcesDir, { recursive: true });
}
fs.writeFileSync(wsdlPath, dummyWsdlContent);
console.log(`Generating client from ${wsdlPath} to ${outputPath}...`);
await generateClient(wsdlPath, outputPath);
console.log('Client generated successfully!');
// Example of using the generated client (requires 'soap' package to be installed)
// In a real scenario, the 'soap' client would be configured to hit a live endpoint.
try {
const client = await createClientAsync(wsdlPath);
// Assuming the generated client has a 'MyService' service and 'MyServiceSOAP' port
const result = await client.MyService.MyServiceSOAP.SayHelloAsync({ name: 'World' });
console.log('SOAP Call Result:', result[0].greeting); // result[0] typically holds the response body
} catch (error) {
console.error('Error using generated client (ensure soap is installed and service is running):', error.message);
}
}
runGenerationAndClient().catch(console.error);
wsdl-tsclient --version
Errors
Common errors & fixes
TypeError: createClientAsync is not a function
The `soap` package, which provides the `createClientAsync` function at runtime, is not installed as a dependency in the project using the generated client.
fixRun `npm install soap` or `yarn add soap` in your project's root directory.
Error: Maximum recursive definition name exceeded. This can lead to very long filenames.
The WSDL contains highly recursive type definitions or many types with very similar names, and `wsdl-tsclient` has reached its limit for creating unique, suffixed names.
fixTry increasing the limit with the `--maxRecursiveDefinitionName` CLI option (e.g., `wsdl-tsclient ... --maxRecursiveDefinitionName 128`), or consider simplifying the WSDL schema if possible.
Cannot find module 'soap' or its corresponding type declarations.
TypeScript cannot resolve the `soap` module. This usually means `soap` is not installed, or type declarations for `soap` are missing or not correctly configured in `tsconfig.json`.
fixEnsure `soap` is installed (`npm i soap`) and, if using TypeScript, that `@types/soap` (if available and needed for an older `soap` version, though `soap` itself often ships types now) is also installed or that `skipLibCheck` is enabled in `tsconfig.json` if type errors persist.
SyntaxError: Cannot use import statement outside a module
You are trying to run a generated client file (or `wsdl-tsclient` itself) that uses ESM `import` statements in a CommonJS-only Node.js environment without proper configuration (e.g., missing `"type": "module"` in `package.json` for ESM output, or not transpiling to CJS). This is particularly relevant if `--esm` flag was used during generation.
fixIf the generated client is intended for ESM, ensure your `package.json` includes `"type": "module"` or use a bundler/transpiler configured for ESM. If targeting CommonJS, avoid the `--esm` flag during generation or ensure your Node.js environment correctly handles ESM interoperability.
Audit
Dependencies
soaprequiredRequired as a runtime dependency for the generated SOAP client to make actual web service calls. wsdl-tsclient generates the types and client wrapper, but `node-soap` handles the underlying SOAP protocol communication.