Announcement Announcement Module
No announcement yet.
Logging SOAP Fault message for non FaultAwareWebServiceConnection Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Logging SOAP Fault message for non FaultAwareWebServiceConnection

    Hi All,

    I have a WebService client application which is using the WebServiceTemplate in Spring-WS v2.1.2.RELEASE to send requests off to remote SOAP WebServices.

    As expected these WebServices sometimes return SOAP Faults to indicate that there was an error processing the request. As such I would like to capture the values returned in the SOAP Fault. Fault code, message etc for auditing and troubleshooting purposes.

    The issue I have is that my code is running inside WebSphere Application server and it appears that the WebService Connection which is returned does not implement "FaultAwareWebServiceConnection" so even if I inject a SOAPFaultMessageResolver into the WebServiceTemplate with checkForError=true and checkForFault=true the FaultMessageResolver is never invoked.

    Rather the handleError method is invoked and a WebServiceTransportException is thrown which unfortunately does not contain the response message i.e:

    Code: Error [500]
    I am thinking that I may need to modify my existing call to sendSourceAndReceiveResult to a sendAndReceive and implement a WebServiceNessageExtractor to check for a SOAP Fault and log this?

    I am also slightly confused as to how I should be implementing the WebServiceMessageCallback in this API call (webServiceTemplate.sendAndReceive(requestCallback , responseExtractor)) to provide my payload as a String?

    Any assistance you can provide in pointing me in the right direction would be much appreciated.

    For reference my current spring context is as follows:

    	<bean id="webServiceTemplate" class="">
    		<property name="interceptors">
    				<ref bean="wssInterceptor" />
    		<property name="messageFactory" ref="messageFactory" />
    <!-- 		<property name="faultMessageResolver"> -->
    <!-- 			<bean class="" /> -->
    <!-- 		</property> -->
    		<property name="checkConnectionForError" value="${check.connection.for.error}" />
    		<property name="checkConnectionForFault" value="${check.connection.for.fault}" />
    	<!-- Explicitly define the SOAP Message factory to avoid issues running in WAS under the IBM JDK -->
    	<bean id="messageFactory" class="" />
    	<!-- Apply the WS-Security authentication headers -->
    	<bean id="wssInterceptor" class="">
    		<property name="securementActions" value="UsernameToken" />
    		<property name="securementMustUnderstand" value="false" />
    		<property name="securementPasswordType" value="PasswordText" />
    		<property name="securementUsername" value="#{dbConfig['USERNAME']}" />
    		<property name="securementPassword" value="#{dbConfig['PASSWORD']}" />
    The client code is currently implemented as follows:

        public String sendAndReceive(final String message, final String uri, final String soapAction) {
            final StreamSource source = new StreamSource(new StringReader(message));
            final StreamResult result = new StringResult();
            webServiceTemplate.sendSourceAndReceiveToResult(uri, source, new SoapActionCallback(soapAction), result);
            return result.toString();
    Patrick Bray