@@ -639,6 +639,7 @@ var WSDL = function(definition, uri, options) {
639
639
}
640
640
641
641
// prepare soap envelope xmlns definition string
642
+ self . _setReduceXmlnsData ( ) ;
642
643
self . xmlnsInEnvelope = self . _xmlnsMap ( ) ;
643
644
644
645
self . callback ( err , self ) ;
@@ -893,11 +894,16 @@ WSDL.prototype.objectToDocumentXML = function(name, params, ns, xmlns) {
893
894
return this . objectToXML ( args , null , ns , xmlns , true ) ;
894
895
}
895
896
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
+
896
902
WSDL . prototype . objectToRpcXML = function ( name , params , namespace , xmlns ) {
897
903
var self = this ,
898
904
parts = [ ] ,
899
905
defs = this . definitions ,
900
- namespace = namespace || findKey ( defs . xmlns , xmlns ) ,
906
+ namespace = this . _getReducedNameSpaceValue ( namespace , xmlns ) ,
901
907
xmlns = xmlns || defs . xmlns [ namespace ] ,
902
908
nsAttrName = '_xmlns' ;
903
909
parts . push ( [ '<' , namespace , ':' , name , '>' ] . join ( '' ) ) ;
@@ -915,6 +921,7 @@ WSDL.prototype.objectToRpcXML = function(name, params, namespace, xmlns) {
915
921
}
916
922
917
923
WSDL . prototype . objectToXML = function ( obj , name , namespace , xmlns , first ) {
924
+ namespace = this . _getReducedNameSpaceValue ( namespace , xmlns ) ;
918
925
var self = this ,
919
926
parts = [ ] ,
920
927
xmlnsAttrib = first ? ' xmlns:' + namespace + '="' + xmlns + '"' + ' xmlns="' + xmlns + '"' : '' ,
@@ -1022,11 +1029,36 @@ WSDL.prototype._xmlnsMap = function() {
1022
1029
if ( ~ ns . indexOf ( 'http://schemas.xmlsoap.org/' ) ) continue ;
1023
1030
if ( ~ ns . indexOf ( 'http://www.w3.org/' ) ) continue ;
1024
1031
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
+ }
1026
1035
}
1027
1036
return str ;
1028
1037
}
1029
1038
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
+
1030
1062
function open_wsdl ( uri , options , callback ) {
1031
1063
if ( typeof options === 'function' ) {
1032
1064
callback = options ;
0 commit comments