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