diff --git a/soap/index.d.ts b/soap/index.d.ts index 8cb9c43424..151e914f63 100644 --- a/soap/index.d.ts +++ b/soap/index.d.ts @@ -10,6 +10,10 @@ import * as events from 'events'; interface Security { } +export interface SoapMethod { + (args: any, callback: (err: any, result: any) => void, options?: any, extraHeaders?: any): void; +} + export class WSSecurity implements Security { constructor(username: string, password: string, options?: any); } @@ -19,12 +23,22 @@ export class ClientSSLSecurity implements Security { constructor(key: Buffer | string, cert: Buffer | string, defaults?: any); } -interface Client extends events.EventEmitter { - setSecurity(s: Security): void; - [method: string]: (args: any, fn: (err: any, result: any) => void, options?: any, extraHeaders?: any) => void; - addSoapHeader(headJSON: any): void; - setEndpoint(endpoint: string): void; +export interface Client extends events.EventEmitter { + addBodyAttribute(bodyAttribute: any, name?: string, namespace?: string, xmlns?: string): void; + addHttpHeader(name: string, value: any): void; + addSoapHeader(soapHeader: any, name?: string, namespace?: string, xmlns?: string): number; + changeSoapHeader(index: number, soapHeader: any, name?: string, namespace?: string, xmlns?: string): void; + clearBodyAttributes(): void; + clearHttpHeaders(): void; + clearSoapHeaders(): void; describe(): any; + getBodyAttributes(): any[]; + getHttpHeaders(): any[]; + getSoapHeaders(): any[]; + setEndpoint(endpoint: string): void; + setSOAPAction(action: string): void; + setSecurity(s: Security): void; + [method: string]: SoapMethod | Function; } export interface Server extends events.EventEmitter { diff --git a/soap/soap-tests.ts b/soap/soap-tests.ts index 48b2e2317e..9771b26efc 100644 --- a/soap/soap-tests.ts +++ b/soap/soap-tests.ts @@ -1,4 +1,3 @@ - import * as soap from 'soap'; import * as events from 'events'; import * as fs from "fs"; @@ -14,18 +13,28 @@ soap.createClient(url, wsdlOptions, function(err: any, client: soap.Client) { client.setSecurity(new soap.ClientSSLSecurity('/path/to/key', '/path/to/cert', '/path/to/ca', defaults)); client.setSecurity(new soap.ClientSSLSecurity('/path/to/key', '/path/to/cert', defaults)); client.setSecurity(new soap.ClientSSLSecurity('/path/to/key', '/path/to/cert', '/path/to/ca')); - client.addSoapHeader({}); client.setEndpoint('http://localhost'); - client['create']({ name: 'value' }, function(err, result) { + client.describe(); + client.addBodyAttribute({}); + client.addHttpHeader('test', true); + client.addSoapHeader({}); + client.changeSoapHeader(0, {}); + client.clearBodyAttributes(); + client.clearHttpHeaders(); + client.clearSoapHeaders(); + client.getBodyAttributes(); + client.getHttpHeaders(); + client.getSoapHeaders(); + client.setSOAPAction('action'); + (client['create'] as soap.SoapMethod)({ name: 'value' }, function(err: any, result: any) { // result is an object }); - client['create']({ name: 'value' }, function(err, result) { + (client['create'] as soap.SoapMethod)({ name: 'value' }, function(err: any, result: any) { // result is an object }, {}); client.on('request', function(obj: any) { //obj is an object }); - client.describe(); }); var myService = {