1.0.6 • Published 3 years ago

simplesoapclient v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Installation

Yarn

yarn add simplesoapclient

Let's register the config module in app.module.ts

import { Module } from '@nestjs/common';
import { SimpleSoapModule } from './simplesoap/simplesoap.module';

@Module({
    imports: [
        SimpleSoapModule.forRoot({
            name: 'SUPER_WSDL_SERVICE',
            wsdl: 'https://example.com/service.svc?singlewsdl',
        })
    ],
})
export class AppModule {}

In app.service.ts

import { Injectable } from '@nestjs/common';
import { InjectSoapClient, SimpleSoapService } from 'simplesoapclient';

@Injectable()
export class AppService {
    constructor(
        @InjectSoapClient('SUPER_WSDL_SERVICE') private readonly service: SimpleSoapService
    ){}

    getHello(args): any {
        return this.service.request<any>('SuperMethod', args)
    }
}

Extended config for module

import {
    httpClient,
    fileCacher,
    ISimplesoapOptions
} from 'simplesoapclient';

const wsdlHeaders = {
    'User-Agent': 'My Super Agent',
}

export const config: ISimplesoapOptions = {
    name: 'SUPER_WSDL_SERVICE',
    wsdl: 'https://example.com/service.svc?singlewsdl',
    soapOptions: {
        httpClient: httpClient, // axios client
        wsdl_headers: wsdlHeaders,

        wsdl_options: {
            timeout: 5000,
            forever: true, // keep-alive
            cacher: fileCacher // custom chacher
        }
    },
};

Cacher interface

interface ISimplesoapCacher {
    get: (key: string) => Promise<string | null>
    save: (key: string, data: string) => Promise<void>
}

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago