View Javadoc

1   /*
2    * Copyright 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.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) throws IOException;
53  
54      /**
55       * Indicates whether this connection has an error. Typically, error detection is done by inspecting connection error
56       * codes, etc.
57       *
58       * @return <code>true</code> if this connection has an error; <code>false</code> otherwise.
59       */
60      boolean hasError() throws IOException;
61  
62      /**
63       * Returns the error message.
64       *
65       * @return the connection error message, if any; returns <code>null</code> when no error is present
66       * @see #hasError()
67       */
68      String getErrorMessage() throws IOException;
69  
70      /**
71       * Closes this connection.
72       * <p/>
73       * Once a connection has been closed, it is not available for further use. A new connection needs to be created.
74       *
75       * @throws IOException if an I/O error occurs when closing this connection
76       */
77      void close() throws IOException;
78  
79  }