Skip to content

Commit 3a38e86

Browse files
Nichew666
authored andcommitted
Allow options in objectToDocumentXML when calling a method
* Options is optional field for objectToDocumentXML function * Replicates `_xml` parameter functionality (sending a custom XML structure as a literal) with JSON arguments.
1 parent afa8cc5 commit 3a38e86

File tree

3 files changed

+2087
-1269
lines changed

3 files changed

+2087
-1269
lines changed

src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ export class Client extends EventEmitter {
413413
} else {
414414
assert.ok(!style || style === 'document', 'invalid message definition for rpc style binding');
415415
// pass `input.$lookupType` if `input.$type` could not be found
416-
message = this.wsdl.objectToDocumentXML(input.$name, args, input.targetNSAlias, input.targetNamespace, (input.$type || input.$lookupType));
416+
message = this.wsdl.objectToDocumentXML(input.$name, args, input.targetNSAlias, input.targetNamespace, (input.$type || input.$lookupType), options);
417417
}
418418

419419
let decodedHeaders;

src/wsdl/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,13 +567,20 @@ export class WSDL {
567567
* @param {String} nsURI
568568
* @param {String} type
569569
*/
570-
public objectToDocumentXML(name: string, params, nsPrefix: string, nsURI?: string, type?: string) {
570+
public objectToDocumentXML(name: string, params, nsPrefix: string, nsURI?: string, type?: string, options?: any) {
571571
// If user supplies XML already, just use that. XML Declaration should not be present.
572572
if (params && params._xml) {
573573
return params._xml;
574574
}
575575
const args = {};
576-
args[name] = params;
576+
const opts = options || {};
577+
if (opts.overrideBaseElement) {
578+
Object.keys(params).forEach((k: string) => {
579+
args[k] = params[k];
580+
});
581+
} else {
582+
args[name] = params;
583+
}
577584
const parameterTypeObj = type ? this.findSchemaObject(nsURI, type) : null;
578585
return this.objectToXML(args, null, nsPrefix, nsURI, true, null, parameterTypeObj);
579586
}

0 commit comments

Comments
 (0)