jeudi 9 avril 2015

Catch WS requests that are syntactically incorrect with Spring Framework

I want to catch and log WS requests that are syntactically incorrect. We are using Spring Framework 3.x


Non of the interceptors is catching this because exception is thrown/catched in org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter during XML parsing.


End Point configuration:



<bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPath" value="com.*.common.schema" />
</bean>

<bean id="messageReceiver" class="org.springframework.ws.soap.server.SoapMessageDispatcher" />

<!-- Endpoint (empty, configured with @Endpoint annotations) -->

<!-- Endpoint Interceptors -->
<bean id="requestLoggingInterceptor" class="com.*.ws.LoggingInterceptor">
<property name="logRequest" value="true" />
<property name="logResponse" value="false" />
<property name="logFault" value="true" />
</bean>

<bean id="responseLoggingInterceptor" class="com.*.ws.LoggingInterceptor">
<property name="logRequest" value="false" />
<property name="logResponse" value="true" />
<property name="logFault" value="false" />
</bean>

<bean id="validatingInterceptor" class="com.*.ws.ValidatingInterceptor">
<property name="schema" value="classpath:com/*/common/schema/*.xsd" />
<property name="exceptionResolver" ref="excpetionResolver" />
</bean>

<bean id="headerSecurityInterceptor" class="com.*.ws.SecurityInterceptor">
<property name="exceptionResolver" ref="excpetionResolver" />
<property name="unmarshaller" ref="jaxb2Marshaller" />
<property name="roles">
<list>
<value>*</value>
</list>
</property>
</bean>

<bean id="wss4jSecurityInterceptor" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
<property name="validationActions" value="UsernameToken" />
<property name="validationCallbackHandler">
<bean class="org.springframework.ws.soap.security.wss4j.callback.SimplePasswordValidationCallbackHandler">
<property name="users">
<props>
<prop key="test">test</prop>
</props>
</property>
</bean>
</property>
</bean>

<!-- Endpoint Mapping -->
<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
<property name="interceptors">
<list>
<ref bean="requestLoggingInterceptor" />
<ref bean="headerSecurityInterceptor" />
<ref bean="validatingInterceptor" />
<ref bean="responseLoggingInterceptor" />
</list>
</property>
</bean>

<!-- Endpoint Adapter -->
<bean class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter">
<constructor-arg ref="jaxb2Marshaller" />
</bean>

Aucun commentaire:

Enregistrer un commentaire