Skip to content

Commit b2c1a13

Browse files
authoredSep 16, 2016
Merge pull request #12 from strongloop/new-tests
Soap 1.1 Fault fix & enabled rest of the tests in wsdl-test.js
2 parents 19ac0c4 + b37d8b9 commit b2c1a13

File tree

5 files changed

+90
-61
lines changed

5 files changed

+90
-61
lines changed
 

‎.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ lib
55
.idea
66
*.iml
77
.vscode
8-
.eslintrc
8+
.eslintrc
9+
.DS_Store
10+

‎src/parser/wsdl/operation.js

+34-24
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Operation extends WSDLElement {
2121
//there can be multiple faults defined in the operation. They all will have same type name 'fault'
2222
//what differentiates them from each other is, the element/s which will get added under fault <detail> during runtime.
2323
this.faults = [];
24+
this.soapVersion;
2425
}
2526

2627
addChild(child) {
@@ -37,6 +38,14 @@ class Operation extends WSDLElement {
3738
case 'operation': // soap:operation
3839
this.soapAction = child.$soapAction || '';
3940
this.style = child.$style || '';
41+
//figure out from the binding operation soap version 1.1 or 1.2
42+
if (child.$soapAction !== undefined){
43+
if(child.nsURI === 'http://schemas.xmlsoap.org/wsdl/soap/'){
44+
this.soapVersion ='1.1';
45+
} else if(child.nsURI === 'http://schemas.xmlsoap.org/wsdl/soap12/') {
46+
this.soapVersion ='1.2';
47+
}
48+
}
4049
break;
4150
}
4251
}
@@ -187,6 +196,7 @@ class Operation extends WSDLElement {
187196
name: this.$name,
188197
style: this.mode,
189198
soapAction: this.soapAction,
199+
soapVersion: this.soapVersion,
190200
input: {
191201
body: input,
192202
headers: inputHeaders
@@ -204,12 +214,12 @@ class Operation extends WSDLElement {
204214
this.descriptor.outputEnvelope =
205215
Operation.createEnvelopeDescriptor(this.descriptor.output, true);
206216
this.descriptor.faultEnvelope =
207-
Operation.createEnvelopeDescriptor(this.descriptor.faults, true);
217+
Operation.createEnvelopeDescriptor(this.descriptor.faults, true, this.soapVersion);
208218

209219
return this.descriptor;
210220
}
211221

212-
static createEnvelopeDescriptor(parameterDescriptor, isOutput, prefix, nsURI) {
222+
static createEnvelopeDescriptor(parameterDescriptor, isOutput, soapVersion, prefix, nsURI) {
213223
prefix = prefix || 'soap';
214224
nsURI = nsURI || 'http://schemas.xmlsoap.org/soap/envelope/';
215225
var descriptor = new TypeDescriptor();
@@ -237,41 +247,41 @@ class Operation extends WSDLElement {
237247
bodyDescriptor.add(parameterDescriptor.headers);
238248
}
239249

240-
//process faults. An example of resulting structure of the <Body> element with <Fault> element descriptor:
250+
//process faults. An example of resulting structure of the <Body> element with soap 1.1 <Fault> element descriptor:
241251
/*
242-
<Body>
243-
<Fault>
244-
<faultcode> </faultcode>
245-
<faultstring> </faultstring>
246-
<faultactor> </faultactor>
247-
<detail>
248-
<myMethodFault1>
249-
<errorMessage1> </errorMessage1>
250-
<value1> </value1>
251-
</myMethodFault1>
252-
</detail>
252+
<soap:Body>
253+
<soap:Fault>
254+
<faultcode>sampleFaultCode</faultcode>
255+
<faultstring>sampleFaultString</faultstring>
253256
<detail>
254-
<myMethodFault2>
255-
<errorMessage2> </errorMessage2>
256-
<value2> </value2>
257-
</myMethodFault2>
257+
<ns1:myMethodFault1 xmlns:ns1="http://example.com/doc_literal_wrapped_test.wsdl">
258+
<errorMessage1>MyMethod Business Exception message</errorMessage1>
259+
<value1>10</value1>
260+
</ns1:myMethodFault1>
258261
</detail>
259-
</Fault>
260-
</Body>
262+
</soap:Fault>
263+
</soap:Body>
261264
*/
262265
if (isOutput && parameterDescriptor && parameterDescriptor.body.Fault) {
263266
let xsdStr = new QName(helper.namespaces.xsd, 'string', 'xsd');
267+
var form;
268+
if (soapVersion === '1.1') {
269+
form = 'unqualified';
270+
} else if (soapVersion === '1.2') {
271+
form = 'qualified';
272+
}
273+
264274
let faultDescriptor = new ElementDescriptor(
265275
new QName(nsURI, 'Fault', prefix), null, 'qualified', false);
266276
bodyDescriptor.add(faultDescriptor);
267277
faultDescriptor.add(
268-
new ElementDescriptor(new QName(nsURI, 'faultcode', prefix), null, 'qualified', false));
278+
new ElementDescriptor(new QName(nsURI, 'faultcode', prefix), null, form, false));
269279
faultDescriptor.add(
270-
new ElementDescriptor(new QName(nsURI, 'faultstring', prefix), null, 'qualified', false));
280+
new ElementDescriptor(new QName(nsURI, 'faultstring', prefix), null, form, false));
271281
faultDescriptor.add(
272-
new ElementDescriptor(new QName(nsURI, 'faultactor', prefix), null, 'qualified', false));
282+
new ElementDescriptor(new QName(nsURI, 'faultactor', prefix), null, form, false));
273283
let detailDescriptor =
274-
new ElementDescriptor(new QName(nsURI, 'detail', prefix), null, 'qualified', false);
284+
new ElementDescriptor(new QName(nsURI, 'detail', prefix), null, form, false);
275285

276286
//multiple faults may be defined in wsdl for this operation. Go though every Fault and add it under <detail> element.
277287
for (var f in parameterDescriptor.body.Fault.faults) {

‎test/wsdl-test.js

+22-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎test/wsdl/typeref/request.json

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
{
2-
"itemRq": {
3-
"ecomRq": {
4-
"rqUID": "001"
5-
},
6-
"item": {
7-
"qty": 100,
8-
"itemId": "item01"
9-
},
10-
"backupItem": {
11-
"qty": 50,
12-
"itemId": "item02"
2+
"orderRq": {
3+
"itemRq": {
4+
"ecomRq": {
5+
"rqUID": "001"
6+
},
7+
"item": {
8+
"qty": 100,
9+
"itemId": "item01"
10+
},
11+
"backupItem": {
12+
"qty": 50,
13+
"itemId": "item02"
14+
}
1315
}
1416
}
1517
}

‎test/wsdl/typeref/request.xml.js

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
module.exports = '<ns1:orderRq xmlns:ns1="http://example.org/ns1" xmlns="http://example.org/ns1">' +
2-
'<ns1:itemRq><ns1:ecomRq><ns2:rqUID xmlns:ns2="http://example.org/ns2">001</ns2:rqUID>' +
3-
'</ns1:ecomRq><ns1:item><qty>100</qty>' +
4-
'<ns2:itemId xmlns:ns2="http://example.org/ns2">item01</ns2:itemId></ns1:item>' +
5-
'<ns2:backupItem xmlns:ns2="http://example.org/ns2"><qty>50</qty>' +
6-
'<ns2:itemId>item02</ns2:itemId></ns2:backupItem></ns1:itemRq></ns1:orderRq>';
1+
module.exports =
2+
'<soap:Body>\n '+
3+
'<ns2:orderRq xmlns:ns2=\"http://example.org/ns1\">\n '+
4+
'<ns2:itemRq>\n '+
5+
'<ns2:ecomRq>\n '+
6+
'<ns3:rqUID xmlns:ns3=\"http://example.org/ns2\">001</ns3:rqUID>\n '+
7+
'</ns2:ecomRq>\n '+
8+
'<ns2:item>\n '+
9+
'<qty>100</qty>\n '+
10+
'<ns3:itemId xmlns:ns3=\"http://example.org/ns2\">item01</ns3:itemId>\n '+
11+
'</ns2:item>\n '+
12+
'<ns3:backupItem xmlns:ns3=\"http://example.org/ns2\">\n '+
13+
'<qty>50</qty>\n '+
14+
'<ns3:itemId>item02</ns3:itemId>\n '+
15+
'</ns3:backupItem>\n '+
16+
'</ns2:itemRq>\n '+
17+
'</ns2:orderRq>\n'+
18+
'</soap:Body>\n';

0 commit comments

Comments
 (0)
Please sign in to comment.