Skip to content

Commit

Permalink
add fields sequence if it's required
Browse files Browse the repository at this point in the history
  • Loading branch information
vfrbgt committed Jan 16, 2017
1 parent 54d20e8 commit 847ec16
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,44 @@ Client.prototype._defineMethod = function(method, location) {
};
};

Client.prototype._isSequenceRequired = function(method) {
try {
if(method.input.children[0].children[0].name === 'sequence') {
return true;
}
return false;
} catch(err) {
return false;
}
};

Client.prototype._setSequenceArgs = function(argsScheme, args) {
var result = {};
if(typeof argsScheme !== 'object') {
return args;
}
for (var partIndex in argsScheme) {
if(typeof args[partIndex] === 'undefined') {
continue;
}
if(typeof argsScheme[partIndex] !== 'object') {
result[partIndex] = args[partIndex];
}
else {
result[partIndex] = this._setSequenceArgs(argsScheme[partIndex], args[partIndex]);
}
}
return result;
};

Client.prototype._getArgsScheme = function(methodName) {
try {
return this.wsdl.definitions.messages[methodName].parts;
} catch(err) {
return false;
}
};

Client.prototype._invoke = function(method, args, location, callback, options, extraHeaders) {
var self = this,
name = method.$name,
Expand All @@ -202,6 +240,13 @@ Client.prototype._invoke = function(method, args, location, callback, options, e
},
xmlnsSoap = "xmlns:" + envelopeKey + "=\"http://schemas.xmlsoap.org/soap/envelope/\"";

if(this._isSequenceRequired(method)) {
var argsScheme = this._getArgsScheme(name);
if(argsScheme) {
args = this._setSequenceArgs(argsScheme, args);
}
}

if (this.wsdl.options.forceSoap12Headers) {
headers["Content-Type"] = "application/soap+xml; charset=utf-8";
xmlnsSoap = "xmlns:" + envelopeKey + "=\"http://www.w3.org/2003/05/soap-envelope\"";
Expand Down

0 comments on commit 847ec16

Please sign in to comment.