Uploaded image for project: 'Spring Web Services'
  1. Spring Web Services
  2. SWS-874

When using @Action and annotation-driven my custom interceptors are not added to the endpoint

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.4
    • Fix Version/s: 2.2.RC1
    • Component/s: None
    • Labels:
      None

      Description

      I have a small spring-ws project with a simple XML config:

      <sws:interceptors>
          <bean class="org.springframework.ws.soap.server.endpoint.interceptor.SoapEnvelopeLoggingInterceptor"/>
      </sws:interceptors>
       
      <sws:annotation-driven/>
      <context:component-scan base-package="package.with.my.endpoints" />
       
      <bean id="messageFactory" class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory">
          <property name="payloadCaching" value="true"/>
      </bean>

      My Endpoint class uses @Action for mapping requests:

      @Endpoint("MedicineCardIdwsEndpoint")
      public class MedicineCardIdws {
          @Action("http://someuriandversion#GetMedicineCardIdws")
          @ResponsePayload
          public Element getMedicineCard(@RequestPayload Element payload, SoapMessage soapMessage) {
              return null; 
          }

      I know this is not a valid implementation, I just want to illustrate that the global interceptor described in the XML config is not getting executed.

      To figure out why I inserted a breakpoint inside org.springframework.ws.soap.server.SoapMessageDispatcher#headerUnderstood and when that breakpoint is triggered I can see that the only interceptor that is registered for my Endpoint is the org.springframework.ws.soap.addressing.server.AddressingEndpointInterceptor which got added because of the Action annotation in my endpoint.

      I thought that any global interceptors in the XML configuration would end up being added to the interceptor chain for all endpoints regardles of how the endpoints were mapped?
      However it seems this is not the case. At first Ifigured I must be doing something wrong, but I cannot find any description of how to add custom interceptors when using @Action. (This is my first time using @Action and Spring-ws, so I may be mistaken)

      If I switch from using @Action to using @SoapAction mappings instead my "XML" interceptors are added just fine.

      When using SoapActions I also have the option of registering interceptors for my mapping using the SoapActionAnnotationMethodEndpointMapping, but I could not find a similar endpointmapping class allowing me to register custom interceptors for WS addressing:

          <bean class="org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping">
              <property name="interceptors">
                  <list>
      <!-- my custom interceptors -->
                  </list>        
              </property>
      </bean>

      The only workaround I could find that would allow me to add my custom interceptors when using @Action was doing as this forum post describes
      http://forum.spring.io/forum/spring-projects/web-services/100060-interceptors-not-working-for-ws-addressing-endpoint-action?p=586915#post586915

      If it is possible to add the interceptors when using WS-Addressing with Spring-ws in a simpler way it would be nice to get this documented. Otherwise I guess it must be a bug that the interceptors are not added to the endpoint?

        Activity

        Hide
        joensson Flemming Jønsson added a comment -

        I forgot to mention that my requests use a soap header with the mustUnderstand="1" attribute - which is why I added the breakpoint in the headerUnderstood method that iterates over the interceptors.

        Show
        joensson Flemming Jønsson added a comment - I forgot to mention that my requests use a soap header with the mustUnderstand="1" attribute - which is why I added the breakpoint in the headerUnderstood method that iterates over the interceptors.
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Indeed, the SoapActionAnnotationMethodEndpointMapping does not have an interceptors property, but it does have a preInterceptors and postInterceptors property, as is described in the last paragraph of the class-level documentation here: http://docs.spring.io/spring-ws/site/apidocs/org/springframework/ws/soap/addressing/server/AbstractAddressingEndpointMapping.html. Granted, it is a bit hidden, but it's documented .

        That said, I will make the WS-Addressing endpoint mappings support the global <sws:interceptors/> block as well.

        Show
        arjen.poutsma Arjen Poutsma added a comment - Indeed, the SoapActionAnnotationMethodEndpointMapping does not have an interceptors property, but it does have a preInterceptors and postInterceptors property, as is described in the last paragraph of the class-level documentation here: http://docs.spring.io/spring-ws/site/apidocs/org/springframework/ws/soap/addressing/server/AbstractAddressingEndpointMapping.html . Granted, it is a bit hidden, but it's documented . That said, I will make the WS-Addressing endpoint mappings support the global <sws:interceptors/> block as well.
        Hide
        joensson Flemming Jønsson added a comment -

        Great news about the sws:interceptors and thank you for pointing out the pre/postInterceptors properties I had missed those when reading the docs.

        Show
        joensson Flemming Jønsson added a comment - Great news about the sws:interceptors and thank you for pointing out the pre/postInterceptors properties I had missed those when reading the docs.
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Fixed. Will be in upcoming 2.2.RC1 release.

        Show
        arjen.poutsma Arjen Poutsma added a comment - Fixed. Will be in upcoming 2.2.RC1 release.

          People

          • Assignee:
            arjen.poutsma Arjen Poutsma
            Reporter:
            joensson Flemming Jønsson
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: