我们有一个spring应用程序,我们有Web服务,它将同时使用PayloadRoot和SoapAction。现在我们在webservice-ws-context.xml
中配置了以下代码<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
<property name="interceptors">
<list>
<bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/>
<bean id="validatingInterceptor" class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
<property name="schema" value="classpath:/xsd/common.xsd"/>
<property name="validateRequest" value="${uiconnect.ws.payload.validate.request}"/>
<property name="validateResponse" value="${uiconnect.ws.payload.validate.response}"/>
</bean>
</list>
</property>
</bean>
现在,我们要为soap操作添加代码,但是如果我们添加以下代码,那么它就不起作用了。那么,我们如何将“id”属性赋予此bean并为特定Web服务配置此bin。或者还有其他方法来配置吗? 我尝试进行自定义端点映射,但是没有帮助。
<bean class="org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping">
<property name="interceptors">
<list>
<bean class="org.springframework.ws.soap.server.endpoint.interceptor.SoapEnvelopeLoggingInterceptor"/>
<bean id="validatingInterceptor" class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
<property name="schema" value="classpath:/xsd/common.xsd"/>
<property name="validateRequest" value="${uiconnect.ws.payload.validate.request}"/>
<property name="validateResponse" value="${uiconnect.ws.payload.validate.response}"/>
</bean>
</list>
</property>
</bean>
答案 0 :(得分:1)
更简单的配置方法是使用Spring-WS提供的自定义命名空间:
首先进行组件扫描以确保找到@Endpoint带注释的bean:
<context:component-scan base-package="..." />
以下内容将在内部注册PayloadRootAnnotationMethodEndpointMapping
和SoapActionAnnotationMethodEndpointMapping
<sws:annotation-driven />
并注册拦截器:
<sws:interceptors>
<bean id="validatingInterceptor" class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
<property name="schema" value="classpath:/xsd/common.xsd"/>
<property name="validateRequest" value="${uiconnect.ws.payload.validate.request}"/>
<property name="validateResponse" value="${uiconnect.ws.payload.validate.response}"/>
</bean>
<sws:payloadRoot namespaceUri="....">
<bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/>
</sws:payloadRoot>
<sws:soapAction value="...">
<bean class="org.springframework.ws.soap.server.endpoint.interceptor.SoapEnvelopeLoggingInterceptor"/>
</sws:soapAction>
</sws:interceptors>**