Results 1 to 4 of 4

Thread: WS Outbound gateway and soap fault

  1. #1

    Default WS Outbound gateway and soap fault

    I want to invoke a soap web service, which I have done it successfully. I will explain the flow as :

    GATEWAY --> HEADER ROUTER --> TRANSFORMER --> WEBSERVICE HEADER ENRICHER --> WEBSERVICE OUTBOUND GATEWAY

    In the webservice outbound gateway, I have attached marshaller and unmwarshaller which will marshall and unmarshall the request and response.

    My question is:
    When there is a SOAP fault, the SOAP webservice return HTTP 200 OK and the response contains the soap fault. This throws unmarshaller failed. Because, the unmarshaller expect a response with no soap fault.
    Can you kindly let me know, what is the best way to handle soap fault? When there is a SOAP fault response, it does not come to the "fault-message-resolver". Below is the code:

    <CODE>
    <ws:outbound-gateway request-channel="serviceChannel" ignore-empty-responses="false"
    message-sender="messageSender"
    fault-message-resolver="faultResolver"
    interceptor="interceptor"
    uri="https://test.com/service/test" >
    </ws:outbound-gateway>
    </CODE>

  2. #2
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    738

    Default

    Hello

    Can you debug, please, what's going on inside the WebServiceTemplate#doSendAndReceive?
    Spring Integration fully delegates to the Spring-WS into this template object and a faultResolver should works just there.

    Let us know how it is.

    Cheers,
    Artem

  3. #3

    Default

    Thanks for the reply.
    I tried to do the same with Spring without using spring integration. I tried with this class "org.springframework.ws.client.core.WebServiceTemp late". Here also, it was not propagating to the fault method that I defined in
    Interceptor class. Then I found that I need to set "checkConnectionForFault" property of WebServiceTemplate class to false. After doing this, it propagate to the fault method. Below is the code:
    <bean id="webserviceTemplate" class="org.springframework.ws.client.core.WebServi ceTemplate">
    <constructor-arg ref="messageFactory" />
    <property name="marshaller" ref="requestMarshaller"></property>
    <property name="unmarshaller" ref="responseUnMarshaller"></property>

    <property name="checkConnectionForFault" value="false"/>
    <property name="faultMessageResolver">
    <bean class="abc.FaultResolver" />
    </property>
    <property name="messageSender">
    <bean
    class="org.springframework.ws.transport.http.Commo nsHttpMessageSender">
    </bean>
    </property>
    <property name="interceptors">
    <list>
    <bean class="abc.HttpHeaderInterceptor" />
    </list>
    </property>
    <property name="defaultUri" value="https://test.com/check" />
    </bean>

    So, my question is, do you have any way of setting this property "checkConnectionForFault" in WebServiceTemplate class to fault from spring integration?

  4. #4
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    738

    Default

    Hello

    The first: wrap, please, your samples with [ CODE ] [ /CODE ] without whitespaces to make your posts more readable.
    The second:
    do you have any way of setting this property "checkConnectionForFault" in WebServiceTemplate class to fault from spring integration?
    No, we don't. You're free to open a JIRA https://jira.springsource.org/browse/INT about your concern and we will think. And I see we don't support checkConnectionForError too.
    The main problem is on the other side, where your external service returns you HTTP 200 OK on the Fault, but not 500 Internal Server Error...
    However I agree with you: if WebServiceTemplate supports it we should in the Spring Integration delegate it in any case.

    To solve your issue right now as workaround will be a bit hard:
    1. You should implement some BeanPostProcessor or write some @PostConstruct method in the @Configuration class.
    2. Add "id" attribute to your <ws:outbound-gateway/>, e.g. "wsOutboundGateway"
    3. Get a Bean from Context by name: "wsOutboundGateway.handler". It will be the object of AbstractWebServiceOutboundGateway
    4. Now you should use this one:
    Code:
    DirectFieldAccessor dfa =  new DirectFieldAccessor(wsOutboundGateway);
    WebServiceTemplate wst = (WebServiceTemplate) dfa.getPropertyValue("webServiceTemplate");
    wst.setCheckConnectionForError(false);
    wst.setCheckConnectionForFault(false);
    5. That's all.

    This "factitious" enrichement must be called on the application start-up.

    Take care and thank you for feedbacks,
    Artem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •