@benasher44/wsdl-tsclient

中文文档
1.4.0发布于 2023/09/15MITTypeScriptCommonJS近 30 天下载 5897

Generate typescript soap client with typescript definitons from WSDL file.

原始使用文档
文档目录8 节
  1. Install
  2. Usage
  3. Generate client using CLI
  4. Generate client programmatically
  5. Using generated client in your project
  6. How it works
  7. License
  8. Contributors

WSDL TSClient

travis-status license Known Vulnerabilities npm-version

Example how to generate and use wsdl-tsclient: wsdl-tsclient-example

Generate a soap client with typescript definitions from a WSDL file.

This library uses ts-morph to generate typescript code and soap for runtime. Inspired by Java wsimport and openapi-generator.

NOTE: Add soap to your npm runtime dependencies (npm i soap).

Install

npm i wsdl-tsclient

or install it with -g to have CLI globally available.

npm i -g wsdl-tsclient

Usage

You can check example repository wsdl-tsclient-example

Generate client using CLI

Easiest way to generate client from is to use CLI. You need to provide only path to .wsdl file and path to output directory (-o param). If you want to generate only typescript types (no runtime code) for node-soap, you can pass --emitDefinitionsOnly param.

wsdl-tsclient ./soap.wsdl -o ./generated

wsdl-tsclient ./resources/**/*.wsdl -o ./generated - using glob

you can also use npx

npx wsdl-tsclient ./soap.wsdl -o ./generated

wsdl-tsclient [options] [path]

Options:
      --help                        Show help                          [boolean]
  -v, --version                                                        [boolean]
  -o                                Output directory         [string] [required]
      --emitDefinitionsOnly         Generate only Definitions          [boolean]
      --modelNamePreffix            Prefix for generated interface names[string]
      --modelNameSuffix             Suffix for generated interface names[string]
      --caseInsensitiveNames        Case-insensitive name while parsing
                                    definition names                   [boolean]
      --maxRecursiveDefinitionName  Maximum count of definition's with same name
                                    but increased suffix. Will throw an error if
                                    exceed                              [number]
      --quiet                       Suppress all logs                  [boolean]
      --verbose                     Print verbose logs                 [boolean]
      --no-color                    Logs without colors                [boolean]

Examples:
    wsdl-tsclient file.wsdl -o ./generated/
    wsdl-tsclient ./res/**/*.wsdl -o ./generated/

Generate client programmatically

import { generateClient } from "wsdl-tsclient";

parseAndGenerate("./path/to/MyWsdl.wsdl", "./generated/");

Using generated client in your project

Note: Make sure you have soap package in your runtime dependencies (npm i soap)

import { createClientAsync } from "./generated/MyWsdl";

const client = await createClientAsync("./path/to/wsdl.wsdl");
client.CallSoapMethodAsync();

Setting basic auth

import soap from "soap";
import { createClientAsync } from "./generated/MyWsdl";

const client = await createClientAsync("./path/to/wsdl.wsdl");

const basicAuth = new soap.BasicAuthSecurity(auth.username, auth.password);
client.setSecurity(basicAuth);

client.CallSoapMethodAsync();

for more information about the use of the client, read more about soap

How it works

overview

License

The source code is licensed under the MIT license

Contributors

Contributors

版本与发布记录

@benasher44/wsdl-tsclient 共发布 1 个版本,首次发布于 2023/09/15;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.4.0latest2023/09/153 年前

关于 @benasher44/wsdl-tsclient 的常见问题

@benasher44/wsdl-tsclient 是什么?

Generate typescript soap client with typescript definitons from WSDL file.

如何安装 @benasher44/wsdl-tsclient?

在项目目录运行 npm install @benasher44/wsdl-tsclient,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 wsdl-tsclient,可以用 npx wsdl-tsclient 直接运行。

@benasher44/wsdl-tsclient 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@benasher44/wsdl-tsclient 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@benasher44/wsdl-tsclient 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=10.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@benasher44/wsdl-tsclient 可以商用吗?

@benasher44/wsdl-tsclient 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@benasher44/wsdl-tsclient 的下载量有多少?

根据 npm 官方下载统计,@benasher44/wsdl-tsclient 在 2026/10/08 – 2026/11/06 这 30 天内被下载 5,897 次,日均约 197 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@benasher44/wsdl-tsclient 还在维护吗?

最新版本 1.4.0 发布于 2023/09/15(3 年前);至今共发布 1 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/09/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。