diff --git a/src/client.ts b/src/client.ts index 1990c2b06..e0095e675 100644 --- a/src/client.ts +++ b/src/client.ts @@ -12,7 +12,7 @@ import * as _ from 'lodash'; import * as request from 'request'; import { v4 as uuidv4 } from 'uuid'; import { HttpClient, Request } from './http'; -import { IHeaders, IOptions, ISecurity, SoapMethod, SoapMethodAsync } from './types'; +import { IHeaders, IHttpClient, IOptions, ISecurity, SoapMethod, SoapMethodAsync } from './types'; import { findPrefix } from './utils'; import { WSDL } from './wsdl'; import { IPort, OperationElement, ServiceElement } from './wsdl/elements'; @@ -56,7 +56,7 @@ export class Client extends EventEmitter { public lastElapsedTime?: number; private wsdl: WSDL; - private httpClient: HttpClient; + private httpClient: IHttpClient; private soapHeaders: any[]; private httpHeaders: IHeaders; private bodyAttributes: string[]; diff --git a/src/http.ts b/src/http.ts index c712d2ba1..efb4f2f8e 100644 --- a/src/http.ts +++ b/src/http.ts @@ -8,15 +8,11 @@ import * as httpNtlm from 'httpntlm'; import * as req from 'request'; import * as url from 'url'; import {v4 as uuidv4} from 'uuid'; -import { IHeaders, IOptions } from './types'; +import { IExOptions, IHeaders, IHttpClient, IOptions } from './types'; const debug = debugBuilder('node-soap'); const VERSION = require('../package.json').version; -export interface IExOptions { - [key: string]: any; -} - export interface IAttachment { name: string; contentId: string; @@ -33,7 +29,7 @@ export type Request = req.Request; * * @constructor */ -export class HttpClient { +export class HttpClient implements IHttpClient { private _request: req.RequestAPI; constructor(options?: IOptions) { diff --git a/src/types.ts b/src/types.ts index f657042e2..09fa634ca 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,11 +1,19 @@ import * as req from 'request'; -import { HttpClient } from './http'; export interface IHeaders { [k: string]: any; } +export interface IExOptions { + [key: string]: any; +} + +export interface IHttpClient { + request(rurl: string, data: any, callback: (error: any, res?: any, body?: any) => any, exheaders?: IHeaders, exoptions?: IExOptions, caller?); + requestStream?(rurl: string, data: any, exheaders?: IHeaders, exoptions?: IExOptions, caller?): req.Request; +} + /** @deprecated use SoapMethod */ export type ISoapMethod = SoapMethod; export type SoapMethod = ( @@ -112,7 +120,7 @@ export interface IOptions extends IWsdlBaseOptions { /** set specific key instead of
. */ envelopeKey?: string; /** provide your own http client that implements request(rurl, data, callback, exheaders, exoptions) */ - httpClient?: HttpClient; + httpClient?: IHttpClient; /** override the request module. */ request?: req.RequestAPI; stream?: boolean;