From 9cc9ec5cda2db0bf54f5de8008bb23d33849656a Mon Sep 17 00:00:00 2001 From: Wilfred van der Deijl Date: Fri, 13 Oct 2017 15:44:13 +0200 Subject: [PATCH] only detect xsi:nil if its value is `true` --- lib/wsdl.js | 4 +- .../Dummy__should_handle_nil_false/common.xsd | 28 +++++++++++++ .../Dummy__should_handle_nil_false/name.xsd | 19 +++++++++ .../request.json | 6 +++ .../request.xml | 1 + .../response.json | 12 ++++++ .../response.xml | 14 +++++++ .../Dummy__should_handle_nil_false/soap.wsdl | 42 +++++++++++++++++++ 8 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 test/request-response-samples/Dummy__should_handle_nil_false/common.xsd create mode 100644 test/request-response-samples/Dummy__should_handle_nil_false/name.xsd create mode 100644 test/request-response-samples/Dummy__should_handle_nil_false/request.json create mode 100644 test/request-response-samples/Dummy__should_handle_nil_false/request.xml create mode 100644 test/request-response-samples/Dummy__should_handle_nil_false/response.json create mode 100644 test/request-response-samples/Dummy__should_handle_nil_false/response.xml create mode 100644 test/request-response-samples/Dummy__should_handle_nil_false/soap.wsdl diff --git a/lib/wsdl.js b/lib/wsdl.js index e3d170bcc..5db76f8cb 100644 --- a/lib/wsdl.js +++ b/lib/wsdl.js @@ -1325,7 +1325,9 @@ WSDL.prototype.xmlToObject = function(xml, callback) { for(attributeName in elementAttributes){ var res = splitQName(attributeName); - if (res.name === 'nil' && xmlns[res.prefix] === 'http://www.w3.org/2001/XMLSchema-instance') { + if (res.name === 'nil' && xmlns[res.prefix] === 'http://www.w3.org/2001/XMLSchema-instance' && elementAttributes[attributeName] && + (elementAttributes[attributeName].toLowerCase() === 'true' || elementAttributes[attributeName] === '1') + ) { hasNilAttribute = true; break; } diff --git a/test/request-response-samples/Dummy__should_handle_nil_false/common.xsd b/test/request-response-samples/Dummy__should_handle_nil_false/common.xsd new file mode 100644 index 000000000..e04c0710b --- /dev/null +++ b/test/request-response-samples/Dummy__should_handle_nil_false/common.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/request-response-samples/Dummy__should_handle_nil_false/name.xsd b/test/request-response-samples/Dummy__should_handle_nil_false/name.xsd new file mode 100644 index 000000000..a515b88c3 --- /dev/null +++ b/test/request-response-samples/Dummy__should_handle_nil_false/name.xsd @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/test/request-response-samples/Dummy__should_handle_nil_false/request.json b/test/request-response-samples/Dummy__should_handle_nil_false/request.json new file mode 100644 index 000000000..52d6f57f7 --- /dev/null +++ b/test/request-response-samples/Dummy__should_handle_nil_false/request.json @@ -0,0 +1,6 @@ +{ + "DummyField1": "Humpty", + "DummyFilter": { + "DummyStringFilter": "Dumpty" + } +} diff --git a/test/request-response-samples/Dummy__should_handle_nil_false/request.xml b/test/request-response-samples/Dummy__should_handle_nil_false/request.xml new file mode 100644 index 000000000..b4ceed77f --- /dev/null +++ b/test/request-response-samples/Dummy__should_handle_nil_false/request.xml @@ -0,0 +1 @@ +HumptyDumpty \ No newline at end of file diff --git a/test/request-response-samples/Dummy__should_handle_nil_false/response.json b/test/request-response-samples/Dummy__should_handle_nil_false/response.json new file mode 100644 index 000000000..f680181d2 --- /dev/null +++ b/test/request-response-samples/Dummy__should_handle_nil_false/response.json @@ -0,0 +1,12 @@ +{ + "DummyResult": { + "DummyList": { + "DummyElement": { + "attributes": { + "xsi:nil": "false" + }, + "$value":"Dummy Element Entry" + } + } + } +} diff --git a/test/request-response-samples/Dummy__should_handle_nil_false/response.xml b/test/request-response-samples/Dummy__should_handle_nil_false/response.xml new file mode 100644 index 000000000..d60ee3c43 --- /dev/null +++ b/test/request-response-samples/Dummy__should_handle_nil_false/response.xml @@ -0,0 +1,14 @@ + + + + + + + + Dummy Element Entry + + + + + + diff --git a/test/request-response-samples/Dummy__should_handle_nil_false/soap.wsdl b/test/request-response-samples/Dummy__should_handle_nil_false/soap.wsdl new file mode 100644 index 000000000..814ba1bf5 --- /dev/null +++ b/test/request-response-samples/Dummy__should_handle_nil_false/soap.wsdl @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +