2

我有两个使用注释的端点。我想对它们中的每一个应用不同的拦截器。(一个是安全拦截器,另一个不安全)有没有办法使用PayloadRootAnnotationMethodEndpointMapping?有人有想法吗?

根据Spring自带的airline example的applicationContext-ws.xml:

端点映射从请求映射到端点。因为我们只希望发生安全拦截,所以 GetFrequentFlyerMileageEndpoint我们定义了两个映射:一个带有 securityInterceptor,一个没有它的通用映射。

那么做到这一点的唯一方法是有两个不同的映射:对于安全的org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping映射?org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping

4

2 回答 2

1

当您将拦截器设置为 时EndpointMapping,这些拦截器将应用于由该 映射的所有端点EndpointMapping。因此,如果您希望某些端点获得与其他端点不同的一组拦截器,那么是的,您需要两个不同EndpointMapping的 bean,一个具有安全拦截器并映射到安全端点,另一个没有拦截器并映射到不安全端点。

EndpointMapping使用的实现取决于应用程序及其使用的端点类型。

于 2009-10-22T07:45:35.150 回答
1

您还可以在应用程序上下文中使用 sws:interceptors 元素来指定具有特定端点的特定拦截器,这些拦截器由它们的 soapAction 或 payloadRoot 属性过滤。

来自: 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"/>
于 2011-07-28T20:42:16.297 回答