1 /* 2 * Copyright 2005-2007 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; 18 19 import java.io.IOException; 20 import java.io.OutputStream; 21 import javax.xml.transform.Result; 22 import javax.xml.transform.Source; 23 24 /** 25 * Represents a protocol-agnostic XML message. 26 * <p/> 27 * <p>Contains methods that provide access to the payload of the message. 28 * 29 * @author Arjen Poutsma 30 * @see org.springframework.ws.soap.SoapMessage 31 * @see WebServiceMessageFactory 32 * @since 1.0.0 33 */ 34 public interface WebServiceMessage { 35 36 /** 37 * Returns the contents of the message as a {@link Source}. <p> Depending on the implementation, this can be 38 * retrieved multiple times, or just a single time. 39 * 40 * @return the message contents 41 */ 42 Source getPayloadSource(); 43 44 /** 45 * Returns the contents of the message as a {@link Result}. 46 * <p/> 47 * Calling this method removes the current payload. 48 * <p/> 49 * Implementations that are read-only will throw an {@link UnsupportedOperationException}. 50 * 51 * @return the message contents 52 * @throws UnsupportedOperationException if the message is read-only 53 */ 54 Result getPayloadResult(); 55 56 /** 57 * Writes the entire message to the given output stream. <p>If the given stream is an instance of {@link 58 * org.springframework.ws.transport.TransportOutputStream}, the corresponding headers will be written as well. 59 * 60 * @param outputStream the stream to write to 61 * @throws IOException if an I/O exception occurs 62 */ 63 void writeTo(OutputStream outputStream) throws IOException; 64 65 }