View Javadoc

1   /*
2    * Copyright 2005-2010 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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.transform.Result;
22  import javax.xml.transform.Source;
23  
24  import org.springframework.ws.soap.SoapBody;
25  
26  /**
27   * SAAJ-specific abstract base class of the <code>SoapBody</code> interface. Wraps a [email protected] javax.xml.soap.SOAPBody}.
28   *
29   * @author Arjen Poutsma
30   * @since 1.0.0
31   */
32  abstract class SaajSoapBody extends SaajSoapElement<SOAPBody> implements SoapBody {
33  
34      public SaajSoapBody(SOAPBody body) {
35          super(body);
36      }
37  
38      public Source getPayloadSource() {
39          SOAPElement bodyElement = getImplementation().getFirstBodyElement(getSaajBody());
40          return bodyElement == null ? null : getImplementation().getSource(bodyElement);
41      }
42  
43      public Result getPayloadResult() {
44          getImplementation().removeContents(getSaajBody());
45          return getImplementation().getResult(getSaajBody());
46      }
47  
48      public boolean hasFault() {
49          return getImplementation().hasFault(getSaajBody());
50      }
51  
52      protected SOAPBody getSaajBody() {
53          return getSaajElement();
54      }
55  
56  }