@@ -21,6 +21,7 @@ class Operation extends WSDLElement {
21
21
//there can be multiple faults defined in the operation. They all will have same type name 'fault'
22
22
//what differentiates them from each other is, the element/s which will get added under fault <detail> during runtime.
23
23
this . faults = [ ] ;
24
+ this . soapVersion ;
24
25
}
25
26
26
27
addChild ( child ) {
@@ -37,6 +38,14 @@ class Operation extends WSDLElement {
37
38
case 'operation' : // soap:operation
38
39
this . soapAction = child . $soapAction || '' ;
39
40
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
+ }
40
49
break ;
41
50
}
42
51
}
@@ -187,6 +196,7 @@ class Operation extends WSDLElement {
187
196
name : this . $name ,
188
197
style : this . mode ,
189
198
soapAction : this . soapAction ,
199
+ soapVersion : this . soapVersion ,
190
200
input : {
191
201
body : input ,
192
202
headers : inputHeaders
@@ -204,12 +214,12 @@ class Operation extends WSDLElement {
204
214
this . descriptor . outputEnvelope =
205
215
Operation . createEnvelopeDescriptor ( this . descriptor . output , true ) ;
206
216
this . descriptor . faultEnvelope =
207
- Operation . createEnvelopeDescriptor ( this . descriptor . faults , true ) ;
217
+ Operation . createEnvelopeDescriptor ( this . descriptor . faults , true , this . soapVersion ) ;
208
218
209
219
return this . descriptor ;
210
220
}
211
221
212
- static createEnvelopeDescriptor ( parameterDescriptor , isOutput , prefix , nsURI ) {
222
+ static createEnvelopeDescriptor ( parameterDescriptor , isOutput , soapVersion , prefix , nsURI ) {
213
223
prefix = prefix || 'soap' ;
214
224
nsURI = nsURI || 'http://schemas.xmlsoap.org/soap/envelope/' ;
215
225
var descriptor = new TypeDescriptor ( ) ;
@@ -237,41 +247,41 @@ class Operation extends WSDLElement {
237
247
bodyDescriptor . add ( parameterDescriptor . headers ) ;
238
248
}
239
249
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:
241
251
/*
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>
253
256
<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 >
258
261
</detail>
259
- </ Fault>
260
- </Body>
262
+ </soap: Fault>
263
+ </soap: Body>
261
264
*/
262
265
if ( isOutput && parameterDescriptor && parameterDescriptor . body . Fault ) {
263
266
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
+
264
274
let faultDescriptor = new ElementDescriptor (
265
275
new QName ( nsURI , 'Fault' , prefix ) , null , 'qualified' , false ) ;
266
276
bodyDescriptor . add ( faultDescriptor ) ;
267
277
faultDescriptor . add (
268
- new ElementDescriptor ( new QName ( nsURI , 'faultcode' , prefix ) , null , 'qualified' , false ) ) ;
278
+ new ElementDescriptor ( new QName ( nsURI , 'faultcode' , prefix ) , null , form , false ) ) ;
269
279
faultDescriptor . add (
270
- new ElementDescriptor ( new QName ( nsURI , 'faultstring' , prefix ) , null , 'qualified' , false ) ) ;
280
+ new ElementDescriptor ( new QName ( nsURI , 'faultstring' , prefix ) , null , form , false ) ) ;
271
281
faultDescriptor . add (
272
- new ElementDescriptor ( new QName ( nsURI , 'faultactor' , prefix ) , null , 'qualified' , false ) ) ;
282
+ new ElementDescriptor ( new QName ( nsURI , 'faultactor' , prefix ) , null , form , false ) ) ;
273
283
let detailDescriptor =
274
- new ElementDescriptor ( new QName ( nsURI , 'detail' , prefix ) , null , 'qualified' , false ) ;
284
+ new ElementDescriptor ( new QName ( nsURI , 'detail' , prefix ) , null , form , false ) ;
275
285
276
286
//multiple faults may be defined in wsdl for this operation. Go though every Fault and add it under <detail> element.
277
287
for ( var f in parameterDescriptor . body . Fault . faults ) {
0 commit comments