1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.soap.saaj;
18
19 import javax.xml.soap.SOAPBody;
20 import javax.xml.soap.SOAPEnvelope;
21 import javax.xml.soap.SOAPException;
22 import javax.xml.soap.SOAPHeader;
23
24 import org.springframework.ws.soap.SoapBody;
25 import org.springframework.ws.soap.SoapEnvelope;
26 import org.springframework.ws.soap.SoapHeader;
27 import org.springframework.ws.soap.SoapVersion;
28
29
30
31
32
33
34
35
36 class SaajSoapEnvelope extends SaajSoapElement<SOAPEnvelope> implements SoapEnvelope {
37
38 private SaajSoapBody body;
39
40 private SaajSoapHeader header;
41
42 private final boolean langAttributeOnSoap11FaultString;
43
44 SaajSoapEnvelope(SOAPEnvelope element, boolean langAttributeOnSoap11FaultString) {
45 super(element);
46 this.langAttributeOnSoap11FaultString = langAttributeOnSoap11FaultString;
47 }
48
49 public SoapBody getBody() {
50 if (body == null) {
51 try {
52 SOAPBody saajBody = getImplementation().getBody(getSaajEnvelope());
53 if (getImplementation().getName(saajBody).getNamespaceURI()
54 .equals(SoapVersion.SOAP_11.getEnvelopeNamespaceUri())) {
55 body = new SaajSoap11Body(saajBody, langAttributeOnSoap11FaultString);
56 }
57 else {
58 body = new SaajSoap12Body(saajBody);
59 }
60 }
61 catch (SOAPException ex) {
62 throw new SaajSoapBodyException(ex);
63 }
64 }
65 return body;
66 }
67
68 public SoapHeader getHeader() {
69 if (header == null) {
70 try {
71 SOAPHeader saajHeader = getImplementation().getHeader(getSaajEnvelope());
72 if (saajHeader != null) {
73 if (getImplementation().getName(saajHeader).getNamespaceURI()
74 .equals(SoapVersion.SOAP_11.getEnvelopeNamespaceUri())) {
75 header = new SaajSoap11Header(saajHeader);
76 }
77 else {
78 header = new SaajSoap12Header(saajHeader);
79 }
80 }
81 else {
82 header = null;
83 }
84 }
85 catch (SOAPException ex) {
86 throw new SaajSoapHeaderException(ex);
87 }
88 }
89 return header;
90 }
91
92 protected SOAPEnvelope getSaajEnvelope() {
93 return getSaajElement();
94 }
95
96 }