01: /*
02: * Copyright 2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.transport;
18:
19: import java.io.IOException;
20:
21: import org.springframework.ws.WebServiceMessage;
22: import org.springframework.ws.WebServiceMessageFactory;
23:
24: /**
25: * Represents a point-to-point connection that a client can use for sending {@link WebServiceMessage} objects directly
26: * to a remote party.
27: * <p/>
28: * A <code>WebServiceConnection</code> can be obtained using a {@link WebServiceMessageSender}.
29: *
30: * @author Arjen Poutsma
31: * @see WebServiceMessageSender#createConnection(String)
32: * @since 1.0.0
33: */
34: public interface WebServiceConnection {
35:
36: /**
37: * Sends the given message using this connection.
38: *
39: * @param message the message to be sent
40: * @throws IOException in case of I/O errors
41: */
42: void send(WebServiceMessage message) throws IOException;
43:
44: /**
45: * Receives a message using the given {@link WebServiceMessageFactory}. This method blocks until it receives, or
46: * returns <code>null</code> when no message is received.
47: *
48: * @param messageFactory the message factory used for reading messages
49: * @return the read message, or <code>null</code> if no message received
50: * @throws IOException in case of I/O errors
51: */
52: WebServiceMessage receive(WebServiceMessageFactory messageFactory)
53: throws IOException;
54:
55: /**
56: * Indicates whether this connection has an error. Typically, error detection is done by inspecting connection error
57: * codes, etc.
58: *
59: * @return <code>true</code> if this connection has an error; <code>false</code> otherwise.
60: */
61: boolean hasError() throws IOException;
62:
63: /**
64: * Returns the error message.
65: *
66: * @return the connection error message, if any; returns <code>null</code> when no error is present
67: * @see #hasError()
68: */
69: String getErrorMessage() throws IOException;
70:
71: /**
72: * Closes this connection.
73: * <p/>
74: * Once a connection has been closed, it is not available for further use. A new connection needs to be created.
75: *
76: * @throws IOException if an I/O error occurs when closing this connection
77: */
78: void close() throws IOException;
79:
80: }
|