001: /*
002: * Copyright 2007 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.saaj;
018:
019: import java.io.IOException;
020: import java.io.OutputStream;
021: import java.util.Iterator;
022: import java.util.Locale;
023: import javax.activation.DataHandler;
024: import javax.xml.namespace.QName;
025: import javax.xml.soap.AttachmentPart;
026: import javax.xml.soap.Detail;
027: import javax.xml.soap.DetailEntry;
028: import javax.xml.soap.MimeHeaders;
029: import javax.xml.soap.SOAPBody;
030: import javax.xml.soap.SOAPElement;
031: import javax.xml.soap.SOAPEnvelope;
032: import javax.xml.soap.SOAPException;
033: import javax.xml.soap.SOAPFault;
034: import javax.xml.soap.SOAPHeader;
035: import javax.xml.soap.SOAPHeaderElement;
036: import javax.xml.soap.SOAPMessage;
037: import javax.xml.transform.Result;
038: import javax.xml.transform.Source;
039:
040: /**
041: * Forms a bridge between the SOAP class hierarchy and a specific version of SAAJ.
042: *
043: * @author Arjen Poutsma
044: * @since 1.0.0
045: */
046: public interface SaajImplementation {
047:
048: /** Returns the name of the given element. */
049: QName getName(SOAPElement element);
050:
051: /** Returns the readable <code>Source</code> of the given element. */
052: Source getSource(SOAPElement element);
053:
054: /** Returns the writable <code>Result</code> of the given element. */
055: Result getResult(SOAPElement element);
056:
057: /** Returns the text of the given element */
058: String getText(SOAPElement element);
059:
060: /** Returns the text of the given element */
061: void setText(SOAPElement element, String content)
062: throws SOAPException;
063:
064: /** Adds an attribute to the specified element. */
065: void addAttribute(SOAPElement element, QName name, String value)
066: throws SOAPException;
067:
068: /** Removes an attribute from the specified element. */
069: void removeAttribute(SOAPElement element, QName name)
070: throws SOAPException;
071:
072: /** Returns the attribute value * */
073: String getAttributeValue(SOAPElement element, QName name)
074: throws SOAPException;
075:
076: /** Returns all attributes as an iterator of QNames. * */
077: Iterator getAllAttibutes(SOAPElement element);
078:
079: /** Returns the envelope of the given message. */
080: SOAPEnvelope getEnvelope(SOAPMessage message) throws SOAPException;
081:
082: /** Returns the header of the given envelope. */
083: SOAPHeader getHeader(SOAPEnvelope envelope) throws SOAPException;
084:
085: /** Returns the body of the given envelope. */
086: SOAPBody getBody(SOAPEnvelope envelope) throws SOAPException;
087:
088: /** Adds a header element to the given header. */
089: SOAPHeaderElement addHeaderElement(SOAPHeader header, QName name)
090: throws SOAPException;
091:
092: /** Returns all header elements. */
093: Iterator examineAllHeaderElements(SOAPHeader header);
094:
095: /** Returns all header elements for which the must understand attribute is true, given the actor or role. */
096: Iterator examineMustUnderstandHeaderElements(SOAPHeader header,
097: String actorOrRole);
098:
099: /** Returns the SOAP 1.1 actor or SOAP 1.2 role attribute for the given header element. */
100: String getActorOrRole(SOAPHeaderElement headerElement);
101:
102: /** Sets the SOAP 1.1 actor or SOAP 1.2 role attribute for the given header element. */
103: void setActorOrRole(SOAPHeaderElement headerElement,
104: String actorOrRole);
105:
106: /** Gets the must understand attribute for the given header element. */
107: boolean getMustUnderstand(SOAPHeaderElement headerElement);
108:
109: /** Sets the must understand attribute for the given header element. */
110: void setMustUnderstand(SOAPHeaderElement headerElement,
111: boolean mustUnderstand);
112:
113: /** Returns <code>true</code> if the body has a fault, <code>false</code> otherwise. */
114: boolean hasFault(SOAPBody body);
115:
116: /** Returns the fault for the given body, if any. */
117: SOAPFault getFault(SOAPBody body);
118:
119: /** Adds a fault to the given body. */
120: SOAPFault addFault(SOAPBody body, QName faultCode,
121: String faultString, Locale locale) throws SOAPException;
122:
123: /** Returns the fault code for the given fault. */
124: QName getFaultCode(SOAPFault fault);
125:
126: /** Returns the actor for the given fault. */
127: String getFaultActor(SOAPFault fault);
128:
129: /** Sets the actor for the given fault. */
130: void setFaultActor(SOAPFault fault, String actorOrRole)
131: throws SOAPException;
132:
133: /** Returns the fault string for the given fault. */
134: String getFaultString(SOAPFault fault);
135:
136: /** Returns the fault string language for the given fault. */
137: Locale getFaultStringLocale(SOAPFault fault);
138:
139: /** Adds a detail entry to the given detail. */
140: DetailEntry addDetailEntry(Detail detail, QName name)
141: throws SOAPException;
142:
143: /** Returns the fault detail for the given fault. */
144: Detail getFaultDetail(SOAPFault fault);
145:
146: /** Adds a fault detail for the given fault. */
147: Detail addFaultDetail(SOAPFault fault) throws SOAPException;
148:
149: void addTextNode(DetailEntry detailEntry, String text)
150: throws SOAPException;
151:
152: /** Returns an iteration over all detail entries. */
153: Iterator getDetailEntries(Detail detail);
154:
155: /** Returns the first child element of the given body. */
156: SOAPElement getFirstBodyElement(SOAPBody body);
157:
158: /** Removes the contents (i.e. children) of the element. */
159: void removeContents(SOAPElement element);
160:
161: /** Writes the given message to the given stream. */
162: void writeTo(SOAPMessage message, OutputStream outputStream)
163: throws SOAPException, IOException;
164:
165: /** Returns the MIME headers of the message. */
166: MimeHeaders getMimeHeaders(SOAPMessage message);
167:
168: /** Returns an iteration over all attachments in the message. */
169: Iterator getAttachments(SOAPMessage message);
170:
171: /** Returns an iteration over all attachments in the message with the given headers. */
172: Iterator getAttachment(SOAPMessage message, MimeHeaders mimeHeaders);
173:
174: /** Adds an attachment to the given message. */
175: AttachmentPart addAttachmentPart(SOAPMessage message,
176: DataHandler dataHandler);
177:
178: /** Adds a not understood header element to the given header. */
179: SOAPHeaderElement addNotUnderstoodHeaderElement(SOAPHeader header,
180: QName name) throws SOAPException;
181:
182: /** Adds a upgrade header element to the given header. */
183: SOAPHeaderElement addUpgradeHeaderElement(SOAPHeader header,
184: String[] supportedSoapUris) throws SOAPException;
185:
186: /** Returns the fault role. */
187: String getFaultRole(SOAPFault fault);
188:
189: /** Sets the fault role. */
190: void setFaultRole(SOAPFault fault, String role)
191: throws SOAPException;
192:
193: /** Returns the fault sub code. */
194: Iterator getFaultSubcodes(SOAPFault fault);
195:
196: /** Adds a fault sub code. */
197: void appendFaultSubcode(SOAPFault fault, QName subcode)
198: throws SOAPException;
199:
200: /** Returns the fault node. */
201: String getFaultNode(SOAPFault fault);
202:
203: /** Sets the fault node. */
204: void setFaultNode(SOAPFault fault, String uri) throws SOAPException;
205:
206: /** Returns the fault reason text. */
207: String getFaultReasonText(SOAPFault fault, Locale locale)
208: throws SOAPException;
209:
210: /** Sets the fault reason text. */
211: void setFaultReasonText(SOAPFault fault, Locale locale, String text)
212: throws SOAPException;
213:
214: }
|