1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.soap;
18
19 import javax.xml.transform.Result;
20 import javax.xml.transform.Source;
21
22 import org.springframework.ws.mime.AbstractMimeMessage;
23
24
25
26
27
28
29
30 public abstract class AbstractSoapMessage extends AbstractMimeMessage implements SoapMessage {
31
32 private SoapVersion version;
33
34
35 public final SoapBody getSoapBody() {
36 return getEnvelope().getBody();
37 }
38
39
40 public final SoapHeader getSoapHeader() {
41 return getEnvelope().getHeader();
42 }
43
44
45 public final Source getPayloadSource() {
46 return getSoapBody().getPayloadSource();
47 }
48
49
50 public final Result getPayloadResult() {
51 return getSoapBody().getPayloadResult();
52 }
53
54
55 public final boolean hasFault() {
56 return getSoapBody().hasFault();
57 }
58
59
60 public final String getFaultReason() {
61 if (hasFault()) {
62 return getSoapBody().getFault().getFaultStringOrReason();
63 }
64 else {
65 return null;
66 }
67 }
68
69 public SoapVersion getVersion() {
70 if (version == null) {
71 String envelopeNamespace = getEnvelope().getName().getNamespaceURI();
72 if (SoapVersion.SOAP_11.getEnvelopeNamespaceUri().equals(envelopeNamespace)) {
73 version = SoapVersion.SOAP_11;
74 }
75 else if (SoapVersion.SOAP_12.getEnvelopeNamespaceUri().equals(envelopeNamespace)) {
76 version = SoapVersion.SOAP_12;
77 }
78 else {
79 throw new IllegalStateException(
80 "Unknown Envelope namespace uri '" + envelopeNamespace + "'. " + "Cannot deduce SoapVersion.");
81 }
82 }
83 return version;
84 }
85 }