Giter Club home page Giter Club logo

wsdl-tsclient's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.