【问题标题】:Get soap fault content with spring message resolver使用 spring 消息解析器获取肥皂故障内容
【发布时间】:2014-05-26 16:43:02
【问题描述】:

我正在使用 spring 集成和 SOAP 来集成外部系统。我在

中添加了 SoapFaultMessageResolver
      <int-ws:outbound-gateway id="mnpOutboundGateway"
                           request-channel="mnpWSRequestChannel"
                           reply-channel="mnpWSResponseChannel"
                           marshaller="mnpMarshaller"
                           unmarshaller="mnpMarshaller"
                           destination-provider="mnpUriProvider"
                           fault-message-resolver="mnpFaultResolver"
                           message-factory="mnpMessageFactory"/>

  <bean name="mnpFaultResolver" class="com.iquest.play.integration.mnp.MnpSoapFaultResolver">

现在我已经覆盖 @Override public void resolveFault(WebServiceMessage message) throws IOException {...

问题是,如何获取 Soap Message 内容(原因、错误代码)?

【问题讨论】:

    标签: spring-integration spring-ws


    【解决方案1】:

    尝试从现有解决方案的来源SoapFaultMessageResolver

    SoapMessage soapMessage = (SoapMessage) message;
    throw new SoapFaultClientException(soapMessage);
    

    并进一步提供 SoapFaultClientException 的源代码(某些部分):

    SoapBody body = faultMessage.getSoapBody();
    soapFault = body != null ? body.getFault() : null;
    ...
    public QName getFaultCode() {
         return soapFault != null ? soapFault.getFaultCode() : null;
    }
    ...
    
    public String getFaultStringOrReason() {
         return soapFault != null ? soapFault.getFaultStringOrReason() : null;
    }
    

    我认为从问题的角度来看就足够了。

    【讨论】:

    • 我试图从WebServiceMessage 中取出它。非常感谢您的帮助,已经是第二次了 :)
    猜你喜欢
    • 2017-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多