View Javadoc

1   /*
2    * Copyright 2008 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.support.interceptor;
18  
19  import org.springframework.ws.client.WebServiceClientException;
20  import org.springframework.ws.context.MessageContext;
21  import org.springframework.ws.soap.SoapHeader;
22  import org.springframework.ws.transport.WebServiceConnection;
23  
24  /**
25   * Workflow interface that allows for customized client-side message interception. Applications can register any number
26   * of existing or custom interceptors on a [email protected] org.springframework.ws.client.core.WebServiceTemplate}, to add common
27   * pre- and postprocessing behavior without needing to modify payload handling code.
28   * <p/>
29   * A <code>ClientInterceptor</code> gets called after payload creation (using [email protected]
30   * org.springframework.ws.client.core.WebServiceTemplate#marshalSendAndReceive(Object)} or similar methods, and after
31   * [email protected] org.springframework.ws.client.core.WebServiceMessageCallback callback} invocation, but before the message is
32   * sent over the [email protected] WebServiceConnection}. This mechanism can be used for a large field of preprocessing aspects,
33   * e.g. for authorization checks, or message header checks. Its main purpose is to allow for factoring out meta-data
34   * (i.e. [email protected] SoapHeader}) related code.
35   * <p/>
36   * Client interceptors are defined on a [email protected] org.springframework.ws.client.core.WebServiceTemplate}, using the [email protected]
37   * org.springframework.ws.client.core.WebServiceTemplate#setInterceptors(ClientInterceptor[]) interceptors} property.
38   *
39   * @author Giovanni Cuccu
40   * @author Arjen Poutsma
41   * @see org.springframework.ws.client.core.WebServiceTemplate#setInterceptors(ClientInterceptor[])
42   * @since 1.5.0
43   */
44  public interface ClientInterceptor {
45  
46      /**
47       * Processes the outgoing request message. Called after payload creation and callback invocation, but before the
48       * message is sent.
49       *
50       * @param messageContext contains the outgoing request message
51       * @return <code>true</code> to continue processing of the request interceptors; <code>false</code> to indicate
52       *         blocking of the request endpoint chain
53       * @throws WebServiceClientException in case of errors
54       * @see MessageContext#getRequest()
55       */
56      boolean handleRequest(MessageContext messageContext) throws WebServiceClientException;
57  
58      /**
59       * Processes the incoming response message. Called for non-fault response messages before payload handling in the
60       * [email protected] org.springframework.ws.client.core.WebServiceTemplate}.
61       *
62       * @param messageContext contains the outgoing request message
63       * @return <code>true</code> to continue processing of the request interceptors; <code>false</code> to indicate
64       *         blocking of the response endpoint chain
65       * @throws WebServiceClientException in case of errors
66       * @see MessageContext#getResponse()
67       */
68      boolean handleResponse(MessageContext messageContext) throws WebServiceClientException;
69  
70      /**
71       * Processes the incoming response fault. Called for response fault messages before payload handling in the [email protected]
72       * org.springframework.ws.client.core.WebServiceTemplate}.
73       *
74       * @param messageContext contains the outgoing request message
75       * @return <code>true</code> to continue processing of the request interceptors; <code>false</code> to indicate
76       *         blocking of the request endpoint chain
77       * @throws WebServiceClientException in case of errors
78       * @see MessageContext#getResponse()
79       * @see org.springframework.ws.FaultAwareWebServiceMessage#hasFault()
80       */
81      boolean handleFault(MessageContext messageContext) throws WebServiceClientException;
82  
83  }