From ff880ddac3afb6a23a053fb43fb99a1ee9cb1545 Mon Sep 17 00:00:00 2001 From: eorsaaq Date: Mon, 20 Jun 2016 17:41:08 +0800 Subject: [PATCH] add two interface:ClientSSLSecurity and setEndpoint --- soap/soap-tests.ts | 3 +++ soap/soap.d.ts | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/soap/soap-tests.ts b/soap/soap-tests.ts index 8010d7285e..100bacf2f5 100644 --- a/soap/soap-tests.ts +++ b/soap/soap-tests.ts @@ -11,7 +11,10 @@ const wsdlOptions = { name: 'value' }; soap.createClient(url, wsdlOptions, function(err: any, client: soap.Client) { let securityOptions = { 'hasTimeStamp': false }; client.setSecurity(new soap.WSSecurity('user', 'password', securityOptions)); + let defaults = {'rejectUnauthorized': false}; + client.setSecurity(new soap.ClientSSLSecurity('/path/to/key', '/path/to/cert', '/path/to/ca',defaults)); client.addSoapHeader({}); + client.setEndpoint('http://localhost'); client['create']({ name: 'value' }, function(err, result) { // result is an object }); diff --git a/soap/soap.d.ts b/soap/soap.d.ts index fa26cbf04c..ce501e9e7a 100644 --- a/soap/soap.d.ts +++ b/soap/soap.d.ts @@ -8,13 +8,19 @@ declare module 'soap' { import * as events from 'events'; - class WSSecurity { + class Security { + } + class WSSecurity extends Security { constructor(username: string, password: string, options: any); } + class ClientSSLSecurity extends Security { + constructor(key: string, cert: string, ca: string, defaults: any); + } interface Client extends events.EventEmitter { - setSecurity(s: WSSecurity): void; + 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; } function createClient(wsdlPath: string, options: any, fn: (err: any, client: Client) => void): void;