# wsdl4ts

> Generate typescript soap client with typescript definitons from WSDL file.

Latest version **1.0.5** (published 2023-09-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install wsdl4ts
pnpm add wsdl4ts
yarn add wsdl4ts
bun add wsdl4ts
```

Provides the command `wsdl-tsclient`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2023-09-21 |
| First published | 2023-09-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=10.0.0 |
| Dependencies | 16 |
| Unpacked size | 184 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Manuel Buslon |
| Maintainers | bass22 |
| Keywords | soap, soap-client, wsdl, wsdl-client, typescript |

## Links

- npm: https://www.npmjs.com/package/wsdl4ts
- Repository: https://github:Shadowsx3/wsdl-tsclient
- Homepage: https://github:Shadowsx3/wsdl-tsclient#readme
- Issues: https://github:Shadowsx3/wsdl-tsclient/issues
- npm.io page: https://npm.io/package/wsdl4ts

## Dependencies (16)

- [glob](https://npm.io/package/glob.md) ^10.3.4
- [chalk](https://npm.io/package/chalk.md) ^4.1.1
- [yargs](https://npm.io/package/yargs.md) ^16.2.0
- [eslint](https://npm.io/package/eslint.md) ^8.13.0
- [ts-morph](https://npm.io/package/ts-morph.md) ^19.0.0
- [camelcase](https://npm.io/package/camelcase.md) ^6.3.0
- [soap4test](https://npm.io/package/soap4test.md) ^1.0.0
- [@types/node](https://npm.io/package/@types/node.md) ^17.0.24
- [@types/tape](https://npm.io/package/@types/tape.md) ^4.13.2
- [@types/yargs](https://npm.io/package/@types/yargs.md) ^16.0.1
- [supports-color](https://npm.io/package/supports-color.md) ^8.1.1
- [sanitize-filename](https://npm.io/package/sanitize-filename.md) ^1.6.3
- [@types/supports-color](https://npm.io/package/@types/supports-color.md) ^8.1.0
- [eslint-plugin-prettier](https://npm.io/package/eslint-plugin-prettier.md) ^4.0.0
- [@typescript-eslint/parser](https://npm.io/package/@typescript-eslint/parser.md) ^5.19.0
- [@typescript-eslint/eslint-plugin](https://npm.io/package/@typescript-eslint/eslint-plugin.md) ^5.19.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2023-09-21
- 1.0.3 — 2023-09-21
- 1.0.2 — 2023-09-20
- 1.0.1 — 2023-09-20
- 1.0.0 — 2023-09-20

## README

# WSDL Two TS

> Temporary fork to include more request and response information in the client callback. In addition, the client parses the objects by class and not by name.

> The original author is Daniel Derevjanik <daniel.derevjanik@gmail.com>

[![travis-status](https://travis-ci.org/dderevjanik/wsdl-tsclient.svg?branch=master)](https://travis-ci.org/dderevjanik/wsdl-tsclient)
![license](https://img.shields.io/npm/l/wsdl-tsclient)
[![Known Vulnerabilities](https://snyk.io/test/github/dderevjanik/wsdl-tsclient/badge.svg)](https://snyk.io/test/github/dderevjanik/wsdl-tsclient)
[![npm-version](https://img.shields.io/npm/v/wsdl-tsclient)](https://npmjs.com/package/wsdl-tsclient)

**Example how to generate and use wsdl-tsclient:** [wsdl-tsclient-example](https://github.com/dderevjanik/wsdl-tsclient-example)

Generate a [soap client](https://www.npmjs.com/package/soap) with typescript definitions from a WSDL file.

This library uses [ts-morph](https://www.npmjs.com/package/ts-morph) to generate typescript code and [soap](https://github.com/vpulim/node-soap) for runtime. Inspired by Java [wsimport](https://docs.oracle.com/javase/8/docs/technotes/tools/unix/wsimport.html) and [openapi-generator](https://github.com/OpenAPITools/openapi-generator).

*NOTE:* Add [soap](https://www.npmjs.com/package/soap) to your npm runtime dependencies (`npm i soap`).

## Install

```sh
npm i wsdl-tsclient
```

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

```sh
npm i -g wsdl-tsclient
```

## Usage

You can check example repository [wsdl-tsclient-example](https://github.com/dderevjanik/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`

```bash
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

```typescript
import { generateClient } from "wsdl-tsclient";

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

### Using generated client in your project

*Note:* Make sure you have [soap](https://www.npmjs.com/package/soap) package in your runtime dependencies (`npm i soap`)

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

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

Setting basic auth 

```typescript
import soap from "soap4test";
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](https://github.com/vpulim/node-soap)

## How it works

![overview](./docs/Overview.png)

## License

The source code is licensed under the [MIT](./LICENSE) license

## Contributors

![Contributors](https://contrib.rocks/image?repo=dderevjanik/wsdl-tsclient)

---
_Source: https://npm.io/package/wsdl4ts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
