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

根据Spring附带的航空公司示例的applicationContext-ws.xml:

  

端点映射从a映射   请求到端点。因为我们   只想要安全拦截   发生的    GetFrequentFlyerMileageEndpoint ,我们   定义两个映射:一个与   securityInterceptor和一般的   没有它。

执行此操作的唯一方法是使用两个不同的映射: org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping org.springframework.ws.server。 endpoint.mapping.PayloadRootQNameEndpointMapping 为安全的?

有帮助吗?

解决方案

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

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

其他提示

您还可以在应用程序上下文中使用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"/>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top