001: /*
002: * Copyright 2006 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.springframework.ws.soap;
018:
019: import java.util.Locale;
020: import javax.xml.transform.Result;
021: import javax.xml.transform.Source;
022:
023: /**
024: * Represents the <code>Body</code> element in a SOAP message. A SOAP body contains the <strong>payload</strong> of the
025: * message. This payload can be custom XML, or a <code>SoapFault</code> (but not both).
026: * <p/>
027: * Note that the source returned by <code>getSource()</code> includes the SOAP Body element itself. For the contents of
028: * the body, use <code>getPayloadSource()</code>.
029: *
030: * @author Arjen Poutsma
031: * @see SoapEnvelope#getBody()
032: * @see #getPayloadSource()
033: * @see #getPayloadResult()
034: * @see SoapFault
035: * @since 1.0.0
036: */
037: public interface SoapBody extends SoapElement {
038:
039: /**
040: * Returns a <code>Source</code> that represents the contents of the body.
041: *
042: * @return the message contents
043: */
044: Source getPayloadSource();
045:
046: /**
047: * Returns a <code>Result</code> that represents the contents of the body.
048: *
049: * @return the message contents
050: */
051: Result getPayloadResult();
052:
053: /**
054: * Adds a <code>MustUnderstand</code> fault to the body. A <code>MustUnderstand</code> is returned when a SOAP
055: * header with a <code>MustUnderstand</code> attribute is not understood.
056: * <p/>
057: * Adding a fault removes the current content of the body.
058: *
059: * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text
060: * @param locale the language of faultStringOrReason. Optional for SOAP 1.1
061: * @return the created <code>SoapFault</code>
062: */
063: SoapFault addMustUnderstandFault(String faultStringOrReason,
064: Locale locale) throws SoapFaultException;
065:
066: /**
067: * Adds a <code>Client</code>/<code>Sender</code> fault to the body. For SOAP 1.1, this adds a fault with a
068: * <code>Client</code> fault code. For SOAP 1.2, this adds a fault with a <code>Sender</code> code.
069: * <p/>
070: * Adding a fault removes the current content of the body.
071: *
072: * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text
073: * @param locale the language of faultStringOrReason. Optional for SOAP 1.1
074: * @return the created <code>SoapFault</code>
075: */
076: SoapFault addClientOrSenderFault(String faultStringOrReason,
077: Locale locale) throws SoapFaultException;
078:
079: /**
080: * Adds a <code>Server</code>/<code>Receiver</code> fault to the body. For SOAP 1.1, this adds a fault with a
081: * <code>Server</code> fault code. For SOAP 1.2, this adds a fault with a <code>Receiver</code> code.
082: * <p/>
083: * Adding a fault removes the current content of the body.
084: *
085: * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text
086: * @param locale the language of faultStringOrReason. Optional for SOAP 1.1
087: * @return the created <code>SoapFault</code>
088: */
089: SoapFault addServerOrReceiverFault(String faultStringOrReason,
090: Locale locale) throws SoapFaultException;
091:
092: /**
093: * Adds a <code>VersionMismatch</code> fault to the body.
094: * <p/>
095: * Adding a fault removes the current content of the body.
096: *
097: * @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text
098: * @param locale the language of faultStringOrReason. Optional for SOAP 1.1
099: * @return the created <code>SoapFault</code>
100: */
101: SoapFault addVersionMismatchFault(String faultStringOrReason,
102: Locale locale) throws SoapFaultException;
103:
104: /**
105: * Indicates whether this body has a <code>SoapFault</code>.
106: *
107: * @return <code>true</code> if the body has a fault; <code>false</code> otherwise
108: */
109: boolean hasFault();
110:
111: /**
112: * Returns the <code>SoapFault</code> of this body.
113: *
114: * @return the <code>SoapFault</code>, or <code>null</code> if none is present
115: */
116: SoapFault getFault();
117: }
|