1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.soap.axiom;
18
19 import org.apache.axiom.om.OMException;
20 import org.apache.axiom.soap.SOAP11Constants;
21 import org.apache.axiom.soap.SOAP12Constants;
22 import org.apache.axiom.soap.SOAPBody;
23 import org.apache.axiom.soap.SOAPEnvelope;
24 import org.apache.axiom.soap.SOAPFactory;
25 import org.apache.axiom.soap.SOAPHeader;
26
27 import org.springframework.ws.soap.SoapBody;
28 import org.springframework.ws.soap.SoapEnvelope;
29 import org.springframework.ws.soap.SoapHeader;
30
31
32
33
34
35
36
37 class AxiomSoapEnvelope extends AxiomSoapElement implements SoapEnvelope {
38
39 boolean payloadCaching;
40
41 private AxiomSoapBody body;
42
43 private final boolean langAttributeOnSoap11FaultString;
44
45 AxiomSoapEnvelope(SOAPEnvelope axiomEnvelope,
46 SOAPFactory axiomFactory,
47 boolean payloadCaching,
48 boolean langAttributeOnSoap11FaultString) {
49 super(axiomEnvelope, axiomFactory);
50 this.payloadCaching = payloadCaching;
51 this.langAttributeOnSoap11FaultString = langAttributeOnSoap11FaultString;
52 }
53
54 public SoapHeader getHeader() {
55 try {
56 if (getAxiomEnvelope().getHeader() == null) {
57 return null;
58 }
59 else {
60 SOAPHeader axiomHeader = getAxiomEnvelope().getHeader();
61 String namespaceURI = getAxiomEnvelope().getNamespace().getNamespaceURI();
62 if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
63 return new AxiomSoap11Header(axiomHeader, getAxiomFactory());
64 }
65 else if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
66 return new AxiomSoap12Header(axiomHeader, getAxiomFactory());
67 }
68 else {
69 throw new AxiomSoapEnvelopeException("Unknown SOAP namespace \"" + namespaceURI + "\"");
70 }
71 }
72 }
73 catch (OMException ex) {
74 throw new AxiomSoapHeaderException(ex);
75 }
76 }
77
78 public SoapBody getBody() {
79 if (body == null) {
80 try {
81 SOAPBody axiomBody = getAxiomEnvelope().getBody();
82 String namespaceURI = getAxiomEnvelope().getNamespace().getNamespaceURI();
83 if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
84 body = new AxiomSoap11Body(axiomBody, getAxiomFactory(), payloadCaching,
85 langAttributeOnSoap11FaultString);
86 }
87 else if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
88 body = new AxiomSoap12Body(axiomBody, getAxiomFactory(), payloadCaching);
89 }
90 else {
91 throw new AxiomSoapEnvelopeException("Unknown SOAP namespace \"" + namespaceURI + "\"");
92 }
93 }
94 catch (OMException ex) {
95 throw new AxiomSoapBodyException(ex);
96 }
97 }
98 return body;
99 }
100
101 protected SOAPEnvelope getAxiomEnvelope() {
102 return (SOAPEnvelope) getAxiomElement();
103 }
104
105 }