From cfb449713c5d504091a7cf2d2c7c13c1e12c9f74 Mon Sep 17 00:00:00 2001
From: lah8789 <11417551+lah8789@users.noreply.github.comy>
Date: Tue, 27 Jul 2021 09:39:20 -0500
Subject: [PATCH] Changes to support the redefining of a namespace alias within
different elements. The provided WSDL was not serializing the response
correctly when returning the XML. Created a request response folder to test
the changes that were made and made sure code coverage remained the same.
---
src/wsdl/elements.ts | 9 ++-
.../bar.xsd | 18 ++++++
.../bar1.xsd | 27 +++++++++
.../request.json | 5 ++
.../request.xml | 1 +
.../response.xml | 10 ++++
.../soap.wsdl | 56 +++++++++++++++++++
7 files changed, 125 insertions(+), 1 deletion(-)
create mode 100644 test/request-response-samples/fooOp__should_return_back_good_response_object/bar.xsd
create mode 100644 test/request-response-samples/fooOp__should_return_back_good_response_object/bar1.xsd
create mode 100644 test/request-response-samples/fooOp__should_return_back_good_response_object/request.json
create mode 100644 test/request-response-samples/fooOp__should_return_back_good_response_object/request.xml
create mode 100644 test/request-response-samples/fooOp__should_return_back_good_response_object/response.xml
create mode 100755 test/request-response-samples/fooOp__should_return_back_good_response_object/soap.wsdl
diff --git a/src/wsdl/elements.ts b/src/wsdl/elements.ts
index 1a81d73d4..4432be403 100644
--- a/src/wsdl/elements.ts
+++ b/src/wsdl/elements.ts
@@ -590,12 +590,19 @@ export class MessageElement extends Element {
const ns = nsName.prefix;
let schema = definitions.schemas[definitions.xmlns[ns]];
this.element = schema.elements[nsName.name];
+ let schemaToLookup;
+ if (!this.element) {
+ // Try to find it another way
+ schemaToLookup = part.xmlns;
+ schema = definitions.schemas[schemaToLookup[Object.keys(schemaToLookup)[0]]];
+ this.element = schema.elements[nsName.name];
+ }
if (!this.element) {
debug(nsName.name + ' is not present in wsdl and cannot be processed correctly.');
return;
}
this.element.targetNSAlias = ns;
- this.element.targetNamespace = definitions.xmlns[ns];
+ this.element.targetNamespace = (schemaToLookup && schemaToLookup.xsns) || definitions.xmlns[ns];
// set the optional $lookupType to be used within `client#_invoke()` when
// calling `wsdl#objectToDocumentXML()
diff --git a/test/request-response-samples/fooOp__should_return_back_good_response_object/bar.xsd b/test/request-response-samples/fooOp__should_return_back_good_response_object/bar.xsd
new file mode 100644
index 000000000..092a6630b
--- /dev/null
+++ b/test/request-response-samples/fooOp__should_return_back_good_response_object/bar.xsd
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/request-response-samples/fooOp__should_return_back_good_response_object/bar1.xsd b/test/request-response-samples/fooOp__should_return_back_good_response_object/bar1.xsd
new file mode 100644
index 000000000..6f100c5cd
--- /dev/null
+++ b/test/request-response-samples/fooOp__should_return_back_good_response_object/bar1.xsd
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/request-response-samples/fooOp__should_return_back_good_response_object/request.json b/test/request-response-samples/fooOp__should_return_back_good_response_object/request.json
new file mode 100644
index 000000000..154258344
--- /dev/null
+++ b/test/request-response-samples/fooOp__should_return_back_good_response_object/request.json
@@ -0,0 +1,5 @@
+{
+ "requestHeader": {
+ "requestId": "79d9372c-d2fe-4f86-a637-d1f5710bb439"
+ }
+}
\ No newline at end of file
diff --git a/test/request-response-samples/fooOp__should_return_back_good_response_object/request.xml b/test/request-response-samples/fooOp__should_return_back_good_response_object/request.xml
new file mode 100644
index 000000000..a6be2a236
--- /dev/null
+++ b/test/request-response-samples/fooOp__should_return_back_good_response_object/request.xml
@@ -0,0 +1 @@
+79d9372c-d2fe-4f86-a637-d1f5710bb439
\ No newline at end of file
diff --git a/test/request-response-samples/fooOp__should_return_back_good_response_object/response.xml b/test/request-response-samples/fooOp__should_return_back_good_response_object/response.xml
new file mode 100644
index 000000000..ad5149051
--- /dev/null
+++ b/test/request-response-samples/fooOp__should_return_back_good_response_object/response.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+ 79d9372c-d2fe-4f86-a637-d1f5710bb439
+
+
+
+
\ No newline at end of file
diff --git a/test/request-response-samples/fooOp__should_return_back_good_response_object/soap.wsdl b/test/request-response-samples/fooOp__should_return_back_good_response_object/soap.wsdl
new file mode 100755
index 000000000..e27932325
--- /dev/null
+++ b/test/request-response-samples/fooOp__should_return_back_good_response_object/soap.wsdl
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+