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 javax.xml.transform.Result;
20 import javax.xml.transform.Source;
21
22 import org.springframework.util.Assert;
23 import org.springframework.ws.soap.SoapBody;
24 import org.springframework.ws.soap.axiom.support.AxiomUtils;
25 import org.springframework.ws.stream.StreamingPayload;
26
27 import org.apache.axiom.om.OMDataSource;
28 import org.apache.axiom.om.OMElement;
29 import org.apache.axiom.soap.SOAPBody;
30 import org.apache.axiom.soap.SOAPFactory;
31
32
33
34
35
36
37
38 abstract class AxiomSoapBody extends AxiomSoapElement implements SoapBody {
39
40 private final Payload payload;
41
42 protected AxiomSoapBody(SOAPBody axiomBody, SOAPFactory axiomFactory, boolean payloadCaching) {
43 super(axiomBody, axiomFactory);
44 if (payloadCaching) {
45 payload = new CachingPayload(axiomBody, axiomFactory);
46 }
47 else {
48 payload = new NonCachingPayload(axiomBody, axiomFactory);
49 }
50 }
51
52 public Source getPayloadSource() {
53 return payload.getSource();
54 }
55
56 public Result getPayloadResult() {
57 return payload.getResult();
58 }
59
60 public boolean hasFault() {
61 return getAxiomBody().hasFault();
62 }
63
64 protected final SOAPBody getAxiomBody() {
65 return (SOAPBody) getAxiomElement();
66 }
67
68 public void setStreamingPayload(StreamingPayload payload) {
69 Assert.notNull(payload, "'payload' must not be null");
70 OMDataSource dataSource = new StreamingOMDataSource(payload);
71 OMElement payloadElement = getAxiomFactory().createOMElement(dataSource, payload.getName());
72
73 SOAPBody soapBody = getAxiomBody();
74 AxiomUtils.removeContents(soapBody);
75 soapBody.addChild(payloadElement);
76 }
77 }