@@ -1424,6 +1424,12 @@ WSDL.prototype.objectToXML = function(obj, name, namespace, xmlns, first, xmlnsA
1424
1424
var self = this ;
1425
1425
var schema = this . definitions . schemas [ xmlns ] ;
1426
1426
1427
+ var parentNamespace = namespace ? namespace . parent : undefined ;
1428
+ if ( parentNamespace ) {
1429
+ //we got the parentNamespace for our array. setting the namespace-variable back to the current namespace string
1430
+ namespace = namespace . current ;
1431
+ }
1432
+
1427
1433
var soapHeader = ! schema ;
1428
1434
var qualified = schema && schema . $elementFormDefault === 'qualified' ;
1429
1435
var parts = [ ] ;
@@ -1456,10 +1462,12 @@ WSDL.prototype.objectToXML = function(obj, name, namespace, xmlns, first, xmlnsA
1456
1462
1457
1463
if ( Array . isArray ( obj ) ) {
1458
1464
for ( var i = 0 , item ; item = obj [ i ] ; i ++ ) {
1459
- var arrayAttr = self . processAttributes ( item ) ;
1460
- parts . push ( [ '<' , ns , name , arrayAttr , xmlnsAttrib , '>' ] . join ( '' ) ) ;
1465
+ var arrayAttr = self . processAttributes ( item ) ,
1466
+ correctOuterNamespace = parentNamespace || ns ; //using the parent namespace if given
1467
+
1468
+ parts . push ( [ '<' , correctOuterNamespace , name , arrayAttr , xmlnsAttrib , '>' ] . join ( '' ) ) ;
1461
1469
parts . push ( self . objectToXML ( item , name , namespace , xmlns , false , null , parameterTypeObject , ancXmlns ) ) ;
1462
- parts . push ( [ '</' , ns , name , '>' ] . join ( '' ) ) ;
1470
+ parts . push ( [ '</' , correctOuterNamespace , name , '>' ] . join ( '' ) ) ;
1463
1471
}
1464
1472
} else if ( typeof obj === 'object' ) {
1465
1473
for ( name in obj ) {
@@ -1522,6 +1530,14 @@ WSDL.prototype.objectToXML = function(obj, name, namespace, xmlns, first, xmlnsA
1522
1530
}
1523
1531
}
1524
1532
1533
+ if ( Array . isArray ( child ) ) {
1534
+ //for arrays, we need to remember the current namespace
1535
+ childNamespace = {
1536
+ current : childNamespace ,
1537
+ parent : ns
1538
+ } ;
1539
+ }
1540
+
1525
1541
value = self . objectToXML ( child , name , childNamespace , childXmlns , false , childXmlnsAttrib , completeChildParameterTypeObject , ancXmlns ) ;
1526
1542
} else if ( obj [ self . options . attributesKey ] && obj [ self . options . attributesKey ] . xsi_type ) { //if parent object has complex type defined and child not found in parent
1527
1543
var completeChildParamTypeObject = self . findChildParameterObjectFromSchema ( obj [ self . options . attributesKey ] . xsi_type . type , obj [ self . options . attributesKey ] . xsi_type . xmlns ) ;
0 commit comments