Skip to content

Commit

Permalink
Merge 20a2136 into fe4cb27
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneRifle committed Mar 4, 2020
2 parents fe4cb27 + 20a2136 commit 26af611
Show file tree
Hide file tree
Showing 18 changed files with 149 additions and 105 deletions.
23 changes: 18 additions & 5 deletions src/parser/xmlHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class XMLHandler {
prefix = prefix || 'soap';
var doc = xmlBuilder.create(prefix + ':Envelope',
{version: '1.0', encoding: 'UTF-8', standalone: true});
nsURI = nsURI || 'http://schemas.xmlsoap.org/soap/envelope/'
nsURI = nsURI || 'http://schemas.xmlsoap.org/soap/envelope/';
doc.attribute('xmlns:' + prefix,
nsURI);
let header = doc.element(prefix + ':Header');
Expand All @@ -395,7 +395,7 @@ class XMLHandler {

static createSOAPEnvelopeDescriptor(prefix, nsURI, parameterDescriptor) {
prefix = prefix || 'soap';
nsURI = nsURI || 'http://schemas.xmlsoap.org/soap/envelope/'
nsURI = nsURI || 'http://schemas.xmlsoap.org/soap/envelope/';
var descriptor = new TypeDescriptor();

var envelopeDescriptor = new ElementDescriptor(
Expand Down Expand Up @@ -648,7 +648,20 @@ class XMLHandler {
top.object = {};
}
if (top.object !== null) {
if (typeof top.object === 'object' && elementName in top.object) {
if (current.descriptor && current.descriptor.isMany) {
// Schema enforces array
let val = top.object[elementName];
if (Array.isArray(val)) {
// Add to the existing array
val.push(current.object);
} else if (!val) {
// Not present, create a new array
top.object[elementName] = [current.object];
} else {
// Convert the element value to an array
top.object[elementName] = [val, current.object];
}
} else if (typeof top.object === 'object' && elementName in top.object) {
// The element exist already, let's create an array
let val = top.object[elementName];
if (Array.isArray(val)) {
Expand Down Expand Up @@ -766,7 +779,7 @@ function getSoap11FaultErrorMessage(faultBody) {
if (typeof detail == 'string') { //plain text
errorMessage = errorMessage + ' detail: ' + detail;
} else { //XML type defined in wsdl
errorMessage = errorMessage + ' detail: ' + JSON.stringify(detail)
errorMessage = errorMessage + ' detail: ' + JSON.stringify(detail);
}
}
}
Expand Down Expand Up @@ -812,7 +825,7 @@ function getSoap12FaultErrorMessage(faultBody) {
if (typeof detail == 'string') { //plain text
errorMessage = errorMessage + ' Detail: ' + detail;
} else { //XML type defined in wsdl
errorMessage = errorMessage + ' Detail: ' + JSON.stringify(detail)
errorMessage = errorMessage + ' Detail: ' + JSON.stringify(detail);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"DummyResult": {
"DummyList": {
"DummyElement": "Dummy Element Entry"
"DummyElement": [
"Dummy Element Entry"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"DummyResult": {
"DummyList": {
"DummyElement": {
"$attributes": {
"language": "en-US"
},
"$value": "Dummy Element Entry"
}
"DummyElement": [
{
"$attributes": {
"language": "en-US"
},
"$value": "Dummy Element Entry"
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"DummyResult": {
"DummyList": {
"DummyElement": {
"$attributes": {
"language": "en-US"
},
"$value": "Dummy Element Entry"
}
"DummyElement": [
{
"$attributes": {
"language": "en-US"
},
"$value": "Dummy Element Entry"
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"DummyResult": {
"DummyList": {
"DummyElement": {
"$attributes": {
"language": "en-US"
},
"$value": "Dummy Element Entry"
}
"DummyElement": [
{
"$attributes": {
"language": "en-US"
},
"$value": "Dummy Element Entry"
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
{
"DummyResult": {
"DummyList": {
"DummyElement": {
"$attributes": {
"language": "en-US"
},
"$value": {
"response": {
"forms": {
"form": {
"$attributes": {
"ObjectId": "1234",
"Form_Name": "Dummy Form"
},
"First_Name": "Humpty",
"Last_Name": "Dumpty"
}
}
}
"DummyElement": [
{
"$attributes": {
"language": "en-US"
},
"$value": {
"response": {
"forms": {
"form": {
"$attributes": {
"ObjectId": "1234",
"Form_Name": "Dummy Form"
},
"First_Name": "Humpty",
"Last_Name": "Dumpty"
}
}
}
}
}
]
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"DummyResult": {
"DummyList": {
"DummyElement": "Dummy Element Entry"
"DummyElement": [
"Dummy Element Entry"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"DummyResult": {
"DummyList": {
"DummyElement": null
"DummyElement": [
null
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"DummyResult": {
"DummyList": {
"DummyElement": {
"$attributes": {
"language": "en-US"
},
"$value": "Dummy Element Entry"
}
"DummyElement": [
{
"$attributes": {
"language": "en-US"
},
"$value": "Dummy Element Entry"
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"DummyResult": {
"DummyList": {
"DummyElement": {
"$attributes": {
"language": "en-US"
},
"$value": "Dummy Element Entry"
}
"DummyElement": [
{
"$attributes": {
"language": "en-US"
},
"$value": "Dummy Element Entry"
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"DummyResult": {
"DummyList": {
"DummyElement": null
"DummyElement": [
null
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"DummyResult": {
"DummyList": {
"DummyElement": {
"$attributes": {
"language": "en-US"
},
"$value": "Dummy Element Entry"
}
"DummyElement": [
{
"$attributes": {
"language": "en-US"
},
"$value": "Dummy Element Entry"
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"DummyResult": {
"DummyList": {
"DummyElement": {
"$attributes": {
"language": "en-US"
},
"$value": "Dummy Element Entry"
}
"DummyElement": [
{
"$attributes": {
"language": "en-US"
},
"$value": "Dummy Element Entry"
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"Result":{
"Result": {
"$attributes": {
"resultStatusFlag": "SUCCESS"
},
"IDs": {
"UniqueID":
"UniqueID": [
{
"$attributes": {
"source": "TESTSOURCE"
},
"$value": "100"
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"Result":{
"Result": {
"$attributes": {
"resultStatusFlag": "SUCCESS"
},
"IDs": {
"UniqueID":
"UniqueID": [
{
"$attributes": {
"source": "TESTSOURCE"
},
"$value": "100"
}
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"Result":{
"Result": {
"$attributes": {
"resultStatusFlag": "SUCCESS"
},
"IDs": {
"UniqueID":
"UniqueID": [
{
"$attributes": {
"source": "TESTSOURCE"
},
"$value": "100"
}
}
]
}
}
}
16 changes: 9 additions & 7 deletions test/request-response-samples/addList__xsi_type/response.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"record": {
"$attributes": {
"$xsiType": { "type": "UserRecord", "xmlns": "urn:example" }
},
"id": "2",
"name": "Mary"
}
"record": [
{
"$attributes": {
"$xsiType": { "type": "UserRecord", "xmlns": "urn:example" }
},
"id": "2",
"name": "Mary"
}
]
}

0 comments on commit 26af611

Please sign in to comment.