Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow options in objectToDocumentXML when calling a method #1096

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
@@ -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;
11 changes: 9 additions & 2 deletions src/wsdl/index.ts
Original file line number Diff line number Diff line change
@@ -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);
}
19 changes: 19 additions & 0 deletions test/client-test.js
Original file line number Diff line number Diff line change
@@ -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('</Request>'), -1);
},
{
overrideBaseElement: true
}
);
done();
});
});