如何捕获骆驼弹簧ws中的肥皂故障细节

时间:2020-05-02 04:57:06

标签: java web-services soap apache-camel

我在我的Spring Boot微服务中使用camel框架2.22.0和camel-spring-ws在运行时将xml转换为soap并发出后端请求,同时接收soap响应并将其转换回XML,然后再发送响应返回到呼叫系统。

成功的场景都可以正常工作,但是当出现肥皂故障时,它只会记录肥皂串,而看不到任何肥皂响应。除http状态代码500之外,soap响应没有被捕获,也没有返回到调用系统。

以下是后端系统作为肥皂故障发送的内容。我看不到骆驼交换体内有肥皂毛病。我需要捕获详细标记部分中的xml响应并将其发送回调用系统。

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <soap:Fault>
          <faultcode>soap:Server</faultcode>
          <faultstring>abc-complex-type.x.x: Value '0' of attribute 'schemaVersion' of element 'ABCSubmission:ABCSubmission' is not valid with respect to the corresponding attribute use. Attribute 'schemaVersion' has a fixed value of '1'.</faultstring>
          <detail>
            <ns2:ABCSubmissionException xmlns:ns2="java:com.webservice.ejb" xmlns="ABCintegration.xdt">
              <ns2:ABCIntegrationError schemaVersionMajor="1" schemaVersionMinor="0">
                <ErrorName>ABCMessageSyntaxInvalid</ErrorName>
                <ErrorDescription>cvc-complex-type.3.1: Value '0' of attribute 'schemaVersion' of element 'ABCSubmission:ABCSubmission' is not valid with respect to the corresponding attribute use. Attribute 'schemaVersion' has a fixed value of '1'.</ErrorDescription>
              </ns2:ABCIntegrationError>
            </ns2:ABCSubmissionException>
          </detail>
        </soap:Fault>
      </soap:Body>
    </soap:Envelope>

1 个答案:

答案 0 :(得分:0)

骆驼区分异常和错误(历史原因)。不幸的是,这似乎在骆驼文档中没有。

如果希望Camel将Fault与Exceptions(由Camel错误处理程序处理)相同,则必须设置

.handleFault()

您可以在骆驼语境或特定路线上进行全局设置。另请参见comment at the bottom of this page