Skip to content

Commit 6da3766

Browse files
committed
Fixed WCF bug.
1 parent 0392b8c commit 6da3766

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

lib/wsdl.js

+34-2
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ var WSDL = function(definition, uri, options) {
639639
}
640640

641641
// prepare soap envelope xmlns definition string
642+
self._setReduceXmlnsData();
642643
self.xmlnsInEnvelope = self._xmlnsMap();
643644

644645
self.callback(err, self);
@@ -893,11 +894,16 @@ WSDL.prototype.objectToDocumentXML = function(name, params, ns, xmlns) {
893894
return this.objectToXML(args, null, ns, xmlns, true);
894895
}
895896

897+
WSDL.prototype._getReducedNameSpaceValue = function(ns, xmlns) {
898+
var namespace = ns || findKey(this.definitions.xmlns, xmlns);
899+
return this.reducedXmlns[namespace] ? this.reducedXmlns[namespace].realXmlAlias : undefined;
900+
}
901+
896902
WSDL.prototype.objectToRpcXML = function(name, params, namespace, xmlns) {
897903
var self = this,
898904
parts = [],
899905
defs = this.definitions,
900-
namespace = namespace || findKey(defs.xmlns, xmlns),
906+
namespace = this._getReducedNameSpaceValue(namespace, xmlns),
901907
xmlns = xmlns || defs.xmlns[namespace],
902908
nsAttrName = '_xmlns';
903909
parts.push(['<',namespace,':',name,'>'].join(''));
@@ -915,6 +921,7 @@ WSDL.prototype.objectToRpcXML = function(name, params, namespace, xmlns) {
915921
}
916922

917923
WSDL.prototype.objectToXML = function(obj, name, namespace, xmlns, first) {
924+
namespace = this._getReducedNameSpaceValue(namespace, xmlns);
918925
var self = this,
919926
parts = [],
920927
xmlnsAttrib = first ? ' xmlns:'+namespace+'="'+xmlns+'"'+' xmlns="'+xmlns+'"' : '',
@@ -1022,11 +1029,36 @@ WSDL.prototype._xmlnsMap = function() {
10221029
if (~ns.indexOf('http://schemas.xmlsoap.org/')) continue;
10231030
if (~ns.indexOf('http://www.w3.org/')) continue;
10241031
if (~ns.indexOf('http://xml.apache.org/')) continue;
1025-
str += ' xmlns:' + alias + '="' + ns + '"';
1032+
if (this.reducedXmlns[alias].realXmlAlias === alias) {
1033+
str += ' xmlns:' + alias + '="' + ns + '"';
1034+
}
10261035
}
10271036
return str;
10281037
}
10291038

1039+
WSDL.prototype._setReduceXmlnsData = function() {
1040+
var xmlns = this.definitions.xmlns;
1041+
var reducedXmlnsMappings = {};
1042+
var reducedXmlns = {};
1043+
for (var alias in xmlns) {
1044+
var ns = xmlns[alias];
1045+
if (!reducedXmlnsMappings[ns]) {
1046+
reducedXmlnsMappings[ns] = alias;
1047+
reducedXmlns[alias] = {
1048+
ns: ns,
1049+
realXmlAlias: alias
1050+
}
1051+
} else {
1052+
reducedXmlns[alias] = {
1053+
ns: ns,
1054+
realXmlAlias: reducedXmlnsMappings[ns]
1055+
}
1056+
}
1057+
}
1058+
this.reducedXmlnsMappings = reducedXmlnsMappings;
1059+
this.reducedXmlns = reducedXmlns;
1060+
}
1061+
10301062
function open_wsdl(uri, options, callback) {
10311063
if (typeof options === 'function') {
10321064
callback = options;

0 commit comments

Comments
 (0)