diff --git a/soap/index.d.ts b/soap/index.d.ts index 9fad90c236..eda277d575 100644 --- a/soap/index.d.ts +++ b/soap/index.d.ts @@ -49,12 +49,31 @@ export interface Server extends events.EventEmitter { log(type: any, data: any): any; } export function listen(server: any, path: string, service: any, wsdl: string): Server; -declare function createClient(wsdlPath: string, options: any, fn: (err: any, client: Client) => void): void; +declare function createClient(wsdlPath: string, options: Option, fn: (err: any, client: Client) => void): void; + +export interface Option { + attributesKey?: string; + disableCache?: boolean; + endpoint?: string; + envelopeKey?: string; + escapeXML?: boolean; + forceSoap12Headers?: boolean; + httpClient?: HttpClient; + ignoreBaseNameSpaces?: boolean, + ignoredNamespaces?: string[] | {namespaces: string[], override: boolean}; + overrideRootElement?: {namespace: string, xmlnsAttributes?: string[]}; + request?: (options: any, callback?: (error: any, res: any, body: any) => void) => void; + stream?: boolean; + valueKey?: string; + wsdl_headers?: { [key: string]: any }; + wsdl_options?: { [key: string]: any }; + xmlKey?: string; +} export class HttpClient { - constructor(options?: any); - buildRequest(rurl: string, data: any | string, exheaders?: any, exoptions?: any): any; + constructor(options?: Option); + buildRequest(rurl: string, data: any | string, exheaders?: { [key: string]: any }, exoptions?: { [key: string]: any }): any; handleResponse(req: any, res: any, body: any | string): any | string; - request(rurl: string, data: any | string, callback: (err: any, res: any, body: any | string) => void, exheaders?: any, exoptions?: any): any; - requestStream(rurl: string, data: any | string, exheaders?: any, exoptions?: any): any; + request(rurl: string, data: any | string, callback: (err: any, res: any, body: any | string) => void, exheaders?: { [key: string]: any }, exoptions?: { [key: string]: any }): any; + requestStream(rurl: string, data: any | string, exheaders?: { [key: string]: any }, exoptions?: { [key: string]: any }): any; } diff --git a/soap/soap-tests.ts b/soap/soap-tests.ts index 0ce95cf585..f07346988e 100644 --- a/soap/soap-tests.ts +++ b/soap/soap-tests.ts @@ -1,10 +1,27 @@ import * as soap from 'soap'; import * as events from 'events'; -import * as fs from "fs"; -import * as http from "http"; +import * as fs from 'fs'; +import * as http from 'http'; const url = 'http://example.com/wsdl?wsdl'; -const wsdlOptions = { name: 'value', httpClient: new soap.HttpClient() }; +// wsdlOptions set only default values +const wsdlOptions = { + attributesKey: 'attributes', + disableCache: false, + endpoint: url, + envelopeKey: 'soap', + escapeXML: true, + forceSoap12Headers: false, + httpClient: new soap.HttpClient(), + ignoreBaseNameSpaces: false, + ignoredNamespaces: ['tns', 'targetNamespace', 'typedNamespace'], + request: require('request'), + stream: false, + wsdl_headers: [], + wsdl_options: [], + valueKey: '$value', + xmlKey: '$xml' +}; soap.createClient(url, wsdlOptions, function(err: any, client: soap.Client) { let securityOptions = { hasTimeStamp: false }; @@ -74,7 +91,7 @@ var myService = { var xml = fs.readFileSync('myservice.wsdl', 'utf8'), server = http.createServer(function(request,response) { - response.end("404: Not Found: " + request.url); + response.end('404: Not Found: ' + request.url); }); server.listen(8000);