01: package org.springframework.ws.soap.axiom;
02:
03: import org.apache.axiom.om.OMException;
04: import org.apache.axiom.soap.SOAP11Constants;
05: import org.apache.axiom.soap.SOAP12Constants;
06: import org.apache.axiom.soap.SOAPBody;
07: import org.apache.axiom.soap.SOAPEnvelope;
08: import org.apache.axiom.soap.SOAPFactory;
09: import org.apache.axiom.soap.SOAPHeader;
10: import org.springframework.ws.soap.SoapBody;
11: import org.springframework.ws.soap.SoapEnvelope;
12: import org.springframework.ws.soap.SoapHeader;
13:
14: /**
15: * Axiom-Specific version of <code>org.springframework.ws.soap.SoapEnvelope</code>.
16: *
17: * @author Arjen Poutsma
18: * @since 1.0.0
19: */
20: class AxiomSoapEnvelope extends AxiomSoapElement implements
21: SoapEnvelope {
22:
23: boolean payloadCaching;
24:
25: private AxiomSoapBody body;
26:
27: public AxiomSoapEnvelope(SOAPEnvelope axiomEnvelope,
28: SOAPFactory axiomFactory, boolean payloadCaching) {
29: super (axiomEnvelope, axiomFactory);
30: this .payloadCaching = payloadCaching;
31: }
32:
33: public SoapHeader getHeader() {
34: try {
35: if (getAxiomEnvelope().getHeader() == null) {
36: return null;
37: } else {
38: SOAPHeader axiomHeader = getAxiomEnvelope().getHeader();
39: String namespaceURI = getAxiomEnvelope().getNamespace()
40: .getNamespaceURI();
41: if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI
42: .equals(namespaceURI)) {
43: return new AxiomSoap11Header(axiomHeader,
44: getAxiomFactory());
45: } else if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI
46: .equals(namespaceURI)) {
47: return new AxiomSoap12Header(axiomHeader,
48: getAxiomFactory());
49: } else {
50: throw new AxiomSoapEnvelopeException(
51: "Unknown SOAP namespace \"" + namespaceURI
52: + "\"");
53: }
54: }
55: } catch (OMException ex) {
56: throw new AxiomSoapHeaderException(ex);
57: }
58: }
59:
60: public SoapBody getBody() {
61: if (body == null) {
62: try {
63: SOAPBody axiomBody = getAxiomEnvelope().getBody();
64: String namespaceURI = getAxiomEnvelope().getNamespace()
65: .getNamespaceURI();
66: if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI
67: .equals(namespaceURI)) {
68: body = new AxiomSoap11Body(axiomBody,
69: getAxiomFactory(), payloadCaching);
70: } else if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI
71: .equals(namespaceURI)) {
72: body = new AxiomSoap12Body(axiomBody,
73: getAxiomFactory(), payloadCaching);
74: } else {
75: throw new AxiomSoapEnvelopeException(
76: "Unknown SOAP namespace \"" + namespaceURI
77: + "\"");
78: }
79: } catch (OMException ex) {
80: throw new AxiomSoapBodyException(ex);
81: }
82: }
83: return body;
84: }
85:
86: protected SOAPEnvelope getAxiomEnvelope() {
87: return (SOAPEnvelope) getAxiomElement();
88: }
89:
90: }
|