Merge pull request #14531 from joshforisha/soap-client

[soap] Add Client interface types
This commit is contained in:
anubmat
2017-02-23 13:25:53 -08:00
committed by GitHub
2 changed files with 33 additions and 10 deletions
+19 -5
View File
@@ -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 {
+14 -5
View File
@@ -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 = {