【问题标题】:ws:outbound-gateway custom interceptor with message headerws:outbound-gateway 带有消息头的自定义拦截器
【发布时间】:2016-06-30 06:43:52
【问题描述】:

我正在使用 ws:outbound-gateway 来调用肥皂服务。我也添加了拦截器。

   <int-ws:outbound-gateway id="wsOutboundGateway"
        request-channel="requestChannel" 
        uri="{soapURI}"
        message-sender="httpMessageSender"
        message-factory="messageFactory"
        interceptor="myInterceptor"
        marshaller="jaxbMarshaller" unmarshaller="jaxbMarshaller">
        <int-ws:uri-variable name="soapURI" expression="headers.soapURI"/>
    </int-ws:outbound-gateway>

myInterceptor 是一个实现 ClientInterceptor 的类。

查询:我在消息头中有需要拦截的信息。有没有办法在拦截器中接收消息头。

注意:我在线程本地设置标头值并现在返回拦截器。

任何更好的解决方案,请提出建议。

【问题讨论】:

    标签: web-services spring-integration


    【解决方案1】:

    这取决于前提和上下文。

    抱歉,您必须分享更多信息。什么是标题?你怎么办?在ClientInterceptor可能不需要拦截,但在&lt;int-ws:outbound-gateway&gt;之前会更好?

    更新

    我在消息头中有信息,我必须在肥皂头中传递它。

    其实ClientInterceptor完全是为了不同的目的,它的意图是不修改消息。

    WebServiceMessageCallback抽象,用于在发送前修改消息。

    但是,如果您有像传递 SOAP 标头这样的要求,我建议您看看像 DefaultSoapHeaderMapper 这样的开箱即用组件。它的populateStandardHeaders 仅处理SoapActionpopulateUserDefinedHeader 仅填充为soapHeader.addAttribute()。因此,考虑对该类进行一些扩展,将自定义标签插入soapHeader。并且已经没有任何ThreadLocal hacks。

    【讨论】:

    • 我在消息头中有信息,我必须在soap头中传递它。
    • 感谢您的建议。我将扩展 DefaultSoapHeaderMapper 并传递肥皂标题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-20
    • 1970-01-01
    • 2020-11-20
    • 2013-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多