Announcement Announcement Module
Collapse
No announcement yet.
Logging SOAP Fault message for non FaultAwareWebServiceConnection Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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:
    org.springframework.ws.client.WebServiceTransportException: Error [500]
            at org.springframework.ws.client.core.WebServiceTemplate.handleError(WebServiceTemplate.java:663)
            at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:587)
            at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:537)
            at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:492)
            at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:436)
    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:

    Code:
    	<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
    		<property name="interceptors">
    			<list>
    				<ref bean="wssInterceptor" />
    			</list>
    		</property>
    		<property name="messageFactory" ref="messageFactory" />
    <!-- 		<property name="faultMessageResolver"> -->
    <!-- 			<bean class="com.anz.otc.dtcc.api.LoggingFaultMessageResolver" /> -->
    <!-- 		</property> -->
    		<property name="checkConnectionForError" value="${check.connection.for.error}" />
    		<property name="checkConnectionForFault" value="${check.connection.for.fault}" />
    	</bean>
    
    	<!-- Explicitly define the SOAP Message factory to avoid issues running in WAS under the IBM JDK -->
    	<bean id="messageFactory" class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory" />
    
    	<!-- Apply the WS-Security authentication headers -->
    	<bean id="wssInterceptor" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
    		<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']}" />
    	</bean>
    The client code is currently implemented as follows:

    Code:
        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();
        }
    Thanks,
    Patrick Bray
Working...
X