diff --git a/src/client.ts b/src/client.ts index ac123d910..fe88e65d2 100644 --- a/src/client.ts +++ b/src/client.ts @@ -387,7 +387,7 @@ export class Client extends EventEmitter { } else { assert.ok(!style || style === 'document', 'invalid message definition for rpc style binding'); // pass `input.$lookupType` if `input.$type` could not be found - message = this.wsdl.objectToDocumentXML(input.$name, args, input.targetNSAlias, input.targetNamespace, (input.$type || input.$lookupType)); + message = this.wsdl.objectToDocumentXML(input.$name, args, input.targetNSAlias, input.targetNamespace, (input.$type || input.$lookupType), options); } let decodedHeaders; diff --git a/src/wsdl/index.ts b/src/wsdl/index.ts index d5c39bb40..c108c047a 100644 --- a/src/wsdl/index.ts +++ b/src/wsdl/index.ts @@ -563,13 +563,20 @@ export class WSDL { * @param {String} nsURI * @param {String} type */ - public objectToDocumentXML(name: string, params, nsPrefix: string, nsURI?: string, type?: string) { + public objectToDocumentXML(name: string, params, nsPrefix: string, nsURI?: string, type?: string, options?: any) { // If user supplies XML already, just use that. XML Declaration should not be present. if (params && params._xml) { return params._xml; } const args = {}; - args[name] = params; + const opts = options || {}; + if (opts.overrideBaseElement) { + Object.keys(params).forEach((k: string) => { + args[k] = params[k]; + }); + } else { + args[name] = params; + } const parameterTypeObj = type ? this.findSchemaObject(nsURI, type) : null; return this.objectToXML(args, null, nsPrefix, nsURI, true, null, parameterTypeObj); } diff --git a/test/client-test.js b/test/client-test.js index e220eca17..13a626359 100644 --- a/test/client-test.js +++ b/test/client-test.js @@ -1557,3 +1557,22 @@ it('should create async client without options', function (done) { done(); }); }); + +it('should replace the InputMessage "Request" element for arg elements', function (done) { + soap.createClient(__dirname + '/wsdl/default_namespace.wsdl', { + ignoredNamespaces: true, + ignoreBaseNameSpaces: true + }, function(err, client) { + assert.ok(client); + client.MyService.MyServicePort.MyOperation( + { parameter: 'dummy' }, + function(err, result, resp, soap, req) { + assert.equal(req.indexOf(''), -1); + }, + { + overrideBaseElement: true + } + ); + done(); + }); +});