From 3a1c6e90ab2a59bbd51f69258bf75a302581ecc4 Mon Sep 17 00:00:00 2001 From: Mik13 Date: Wed, 15 Mar 2017 08:27:10 +0100 Subject: [PATCH] Fix missing namespace declaration on array if the namespace is already declared with another prefix. (#923) --- lib/wsdl.js | 5 +- .../request.xml | 2 +- .../request.xml | 2 +- .../Common.xsd | 43 +++++++++++++++++ .../Name.xsd | 47 ++++++++++++++++++ .../request.json | 48 +++++++++++++++++++ .../request.xml | 1 + .../response.json | 15 ++++++ .../response.xml | 1 + .../soap.wsdl | 43 +++++++++++++++++ .../request.xml | 2 +- 11 files changed, 205 insertions(+), 4 deletions(-) create mode 100644 test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/Common.xsd create mode 100644 test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/Name.xsd create mode 100644 test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/request.json create mode 100644 test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/request.xml create mode 100644 test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/response.json create mode 100644 test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/response.xml create mode 100644 test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/soap.wsdl diff --git a/lib/wsdl.js b/lib/wsdl.js index 68b7bfcb2..6e7318468 100644 --- a/lib/wsdl.js +++ b/lib/wsdl.js @@ -1817,10 +1817,13 @@ WSDL.prototype.objectToXML = function(obj, name, nsPrefix, nsURI, isFirst, xmlns current: childNsPrefix, parent: ns }; + } else { + //parent (array) already got the namespace + childXmlnsAttrib = null; } value = self.objectToXML(child, name, childNsPrefix, childNsURI, - false, null, resolvedChildSchemaObject, nsContext); + false, childXmlnsAttrib, resolvedChildSchemaObject, nsContext); } 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 var completeChildParamTypeObject = self.findChildSchemaObject( diff --git a/test/request-response-samples/UpdateProfile__correct_namespaces_for_elements_with_base/request.xml b/test/request-response-samples/UpdateProfile__correct_namespaces_for_elements_with_base/request.xml index c52da69db..61a81f655 100644 --- a/test/request-response-samples/UpdateProfile__correct_namespaces_for_elements_with_base/request.xml +++ b/test/request-response-samples/UpdateProfile__correct_namespaces_for_elements_with_base/request.xml @@ -1 +1 @@ -100Another AddressMy Address123456 \ No newline at end of file +100Another AddressMy Address123456 \ No newline at end of file diff --git a/test/request-response-samples/UpdateProfile__correct_namespaces_in_sequence_with_imports/request.xml b/test/request-response-samples/UpdateProfile__correct_namespaces_in_sequence_with_imports/request.xml index d1d7c8dfb..3b6cf6afd 100644 --- a/test/request-response-samples/UpdateProfile__correct_namespaces_in_sequence_with_imports/request.xml +++ b/test/request-response-samples/UpdateProfile__correct_namespaces_in_sequence_with_imports/request.xml @@ -1 +1 @@ -10012 \ No newline at end of file +10012 \ No newline at end of file diff --git a/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/Common.xsd b/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/Common.xsd new file mode 100644 index 000000000..31979f117 --- /dev/null +++ b/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/Common.xsd @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/Name.xsd b/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/Name.xsd new file mode 100644 index 000000000..a091e4a4f --- /dev/null +++ b/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/Name.xsd @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + Collection of NamePhone + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/request.json b/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/request.json new file mode 100644 index 000000000..3a3dbc540 --- /dev/null +++ b/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/request.json @@ -0,0 +1,48 @@ +{ + "Profile": { + "IDs": { + "UniqueID": [ + { + "attributes": { + "source": "TESTSOURCE" + }, + "$value": 100 + } + ] + }, + "Phones": { + "NamePhone": [ + { + "attributes": { + "primary": true + }, + "IDs": { + "UniqueID": [ + { + "attributes": { + "source": "TEST" + }, + "$value": 1 + } + ] + } + }, + { + "attributes": { + "primary": false + }, + "IDs": { + "UniqueID": [ + { + "attributes": { + "source": "TEST" + }, + "$value": 2 + } + ] + } + } + ] + } + } +} \ No newline at end of file diff --git a/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/request.xml b/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/request.xml new file mode 100644 index 000000000..fad6e0c2d --- /dev/null +++ b/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/request.xml @@ -0,0 +1 @@ +10012 \ No newline at end of file diff --git a/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/response.json b/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/response.json new file mode 100644 index 000000000..a281a8edd --- /dev/null +++ b/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/response.json @@ -0,0 +1,15 @@ +{ + "Result":{ + "attributes": { + "resultStatusFlag": "SUCCESS" + }, + "IDs": { + "UniqueID": { + "attributes": { + "source": "TESTSOURCE" + }, + "$value": "100" + } + } + } +} diff --git a/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/response.xml b/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/response.xml new file mode 100644 index 000000000..223079d90 --- /dev/null +++ b/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/response.xml @@ -0,0 +1 @@ +100 \ No newline at end of file diff --git a/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/soap.wsdl b/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/soap.wsdl new file mode 100644 index 000000000..2076cd354 --- /dev/null +++ b/test/request-response-samples/UpdateProfile__correct_namespaces_other_prefixes/soap.wsdl @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/request-response-samples/UpdateProfile__correct_ns_context/request.xml b/test/request-response-samples/UpdateProfile__correct_ns_context/request.xml index 12b5ba2e9..8176b6ccf 100644 --- a/test/request-response-samples/UpdateProfile__correct_ns_context/request.xml +++ b/test/request-response-samples/UpdateProfile__correct_ns_context/request.xml @@ -1 +1 @@ -100100100Another AddressMy Address123456 \ No newline at end of file +100100100Another AddressMy Address123456 \ No newline at end of file