Question

I have two endpoints using annotations. I want to apply different interceptors to each of them. (one being a secure interceptor and the other not being secure) Is there a way to do this using PayloadRootAnnotationMethodEndpointMapping? Anyone have an idea?

According to the applicationContext-ws.xml of the airline example that comes with Spring:

The endpoint mappings map from a request to an endpoint. Because we only want the security interception to occur for the GetFrequentFlyerMileageEndpoint, we define two mappings: one with the securityInterceptor, and a general one without it.

So is the only way to do this is to have two different mappings: org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping and org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping for the secure ones?

Was it helpful?

Solution

When you give an interceptor set to an EndpointMapping, then those interceptors will apply to all Endpoints mapped by that EndpointMapping. So if you want some Endpoints to get a different set of interceptors to other Endpoints, then yes, you need two different EndpointMapping beans, one with the secure interceptor and mapping to the secure endpoints, and another with no interceptors and mapping to the unsecured endpoints.

Which EndpointMapping implementations you use is dependent on the application and which kinds of Endpoints it uses.

OTHER TIPS

You can also use the sws:interceptors element in your application context to specify particular interceptors with particular endpoints, filtered by their soapAction or payloadRoot attributes.

From: http://static.springsource.org/spring-ws/site/reference/html/server.html#server-endpoint-interceptor

<sws:interceptors>
  <bean class="samples.MyGlobalInterceptor"/>
  <sws:payloadRoot namespaceUri="http://www.example.com">
    <bean class="samples.MyPayloadRootInterceptor"/>
  </sws:payloadRoot>
  <sws:soapAction value="http://www.example.com/SoapAction">
    <bean class="samples.MySoapActionInterceptor1"/>
    <ref bean="mySoapActionInterceptor2"/>
  </sws:soapAction>
</sws:interceptors>

<bean id="mySoapActionInterceptor2" class="samples.MySoapActionInterceptor2"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top