Spring integration 在http网关spring集成上记录SOAP消息

Spring integration 在http网关spring集成上记录SOAP消息,spring-integration,Spring Integration,我使用SpringIntegration(4.0.6)从rest服务使用INTHTTP:OutboundGateway和INTWS:OutboundGateway进行SOAP调用。是否有方法仅在异常情况下记录SOAP请求消息 <int:gateway id="myGateway" service-interface="myservice"> <int:method name="getData" request-channel="reqChannel" reply-cha

我使用SpringIntegration(4.0.6)从rest服务使用INTHTTP:OutboundGateway和INTWS:OutboundGateway进行SOAP调用。是否有方法仅在异常情况下记录SOAP请求消息

<int:gateway id="myGateway" service-interface="myservice">
    <int:method name="getData" request-channel="reqChannel" reply-channel="repChannel">
</int-gateway>

我的出站网关配置如下

<int-http:outbound-gateway id="og1" request-channel="reqChannel" url="xxx" http-method="POST" reply-channel="repChannel" reply-timeout="10000" message-converters="converter" request-factory="reqFactory">

<bean id="reqFactory"
     class="org.springframework.http.client.SimpleClientHttpRequestFactory">
    <property name="cTimeout" value="20000"/>
    <property name="rTimeout"    value="20000"/>
</bean>

最好共享一些配置和您希望从中获取日志/异常的点

<int:gateway id="myGateway" service-interface="myservice">
    <int:method name="getData" request-channel="reqChannel" reply-channel="repChannel">
</int-gateway>
都具有
功能,您可以使用
表达式评估requesthandleradvice
并为任何诊断发送带有请求(有罪?)消息的
错误消息

您应该在相应的
clienthtprequestfactory
上配置
readTimeout
,例如
httpcomponents客户端httprequestfactory\setReadTimeout(int timeout)

关于转换器,希望在出现错误时记录其结果

如何使用所需的逻辑实现
clienthttpprequestinterceptor

try {
   return execution.execute(request, body);
catch (Exception e) {
   this.errorChannel.send(...);
}
我很确定
byte[]body
是您的SOAP请求

有关更多信息,请参见
clienthttpprequestinterceptor
JavaDocs

clienthttpprequestinterceptor
restemplate
的一部分,可以将其注入
http:outbound gateway

对于
ws:outbound gateway
,您应该将
ClientInterceptor
handleFault
实现一起使用,并提取
MessageContext.getRequest()

好的,尝试此方法。 创建自己的错误处理程序,它实现spring错误处理程序接口。在您的上下文文件中

<bean id="soapErrorHandlingSyncTaskExecutor"
    class="org.springframework.integration.util.ErrorHandlingTaskExecutor">
        <constructor-arg>
            <bean class="org.springframework.core.task.SyncTaskExecutor" />
        </constructor-arg>
        <constructor-arg>
            <bean class="ErrorHandle" 
p:errorSender-ref="errorSender"/>
        </constructor-arg>
    </bean>
<bean id="errorSender" class="org.springframework.integration.core.MessagingTemplate"
        p:defaultChannel-ref="errors" />

当您的WS-adapter抛出任何异常时,org.springframework.integration.util.ErrorHandlingTaskExecutor会捕获该异常,现在由您决定如何在错误处理程序中处理该异常

SOAP faultcode和faultstring位于MessaginException的原因中(如果是SoapFaultClientException)

在这里,我将错误消息发送到一个通道,供我监视


希望这有帮助。

否,请编辑您的问题并在此处共享更多信息。或者试试看我的答案对你来说是否足够,我可以继续为其他人提供帮助。请将答案移到你的问题上,并正确设置格式以提高可读性。在
级别上,你可以配置
接收超时
错误频道
。有关更多信息,请参阅参考手册:我刚刚在答案中添加了关于
restemplate
的注释,您的配置中的所有内容都是我想要看到的。不知道你有什么问题。。。也许逐行调试它以确定要提取的正确属性会更好。虽然对我来说,
clienthttpprequestinterceptor
确实想要发送
SOAP请求
,但请停止破坏您的文章,将其回滚到早期的、不完整的版本。如果您希望请求解除关联,以便您的姓名不再与文章关联,请使用页面底部的“联系我们”链接。我昨天两次联系(与我们联系)删除了我的文章及其修订版。你能帮我删除这篇文章的修改和文章吗。谢谢你。@HariBajavada今天是周末。这些东西在周末花的时间更长。