View Javadoc

1   /*
2    * Copyright 2005-2010 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.client.core;
18  
19  import java.io.IOException;
20  import javax.xml.transform.TransformerException;
21  
22  import org.springframework.ws.WebServiceMessage;
23  
24  /**
25   * Callback interface for extracting a result object from a [email protected] WebServiceMessage} instance.
26   * <p/>
27   * Used for output object creation in [email protected] WebServiceTemplate}. Alternatively, output messages can also be returned to
28   * client code as-is. In case of a message as execution result, you will almost always want to implement a
29   * <code>WebServiceMessageExtractor</code>, to be able to read the message in a managed fashion, with the connection
30   * still open while reading the message.
31   * <p/>
32   * Implementations of this interface perform the actual work of extracting results, but don't need to worry about
33   * exception handling, or resource handling.
34   *
35   * @author Arjen Poutsma
36   * @since 1.0.0
37   */
38  public interface WebServiceMessageExtractor<T> {
39  
40      /**
41       * Process the data in the given <code>WebServiceMessage</code>, creating a corresponding result object.
42       *
43       * @param message the message to extract data from (possibly a <code>SoapMessage</code>)
44       * @return an arbitrary result object, or <code>null</code> if none (the extractor will typically be stateful in the
45       *         latter case)
46       * @throws IOException          in case of I/O errors
47       * @throws TransformerException in case of transformation errors
48       */
49      T extractData(WebServiceMessage message) throws IOException, TransformerException;
50  
51  }