gpt4 book ai didi

java - 如何在camel-spring-ws中捕获 SOAP 故障细节

转载 作者:行者123 更新时间:2023-12-01 16:58:16 25 4
gpt4 key购买 nike

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

成功场景都工作正常,但当 SOAP 故障时,它只记录 SOAP 字符串,看不到任何 SOAP 响应已填充。 SOAP 响应没有被捕获,除了 http 状态代码 500 之外,也不会返回到调用系统。

以下是后端系统作为 SOAP 故障发送的内容。我在 Camel 交换体中看不到任何充满 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>

最佳答案

Camel 区分异常和错误(历史原因)。不幸的是,Camel 文档中似乎缺少这一点。

如果您希望 Camel 将故障视为异常(由 Camel 错误处理程序处理),则必须设置

.handleFault()

您可以在 Camel 上下文或特定路由上进行全局设置。另请参阅comment at the bottom of this page

关于java - 如何在camel-spring-ws中捕获 SOAP 故障细节,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61554669/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com