【问题标题】:Calling a soap service through spring integration along with http headers通过 Spring 集成和 http 标头调用soap服务
【发布时间】:2015-01-20 12:25:35
【问题描述】:

我正在开发用于调用肥皂服务的 spring 集成。我能够成功地使用出站网关调用肥皂服务。现在我需要使用相同的请求调用相同的肥皂服务,现在我需要在 http 标头中添加一些参数。任何人都可以帮助我完成这项任务。非常感谢您提前。

【问题讨论】:

    标签: java spring web-services soap spring-integration


    【解决方案1】:

    你可以用request-callback注入到<int-ws:outbound-gateway>来实现:

    public class AddHeaderWebServiceMessageCallback implements WebServiceMessageCallback {
    
      public void doWithMessage(WebServiceMessage message) {
                CommonsHttpConnection connection = (CommonsHttpConnection) context.getConnection();
                PostMethod postMethod = connection.getPostMethod();
                postMethod.addRequestHeader( "foo", "bar" );
            }
    
    }
    

    或者...如果您需要为每个requestMessage 动态地执行此操作,您应该使用自定义SoapHeaderMapper 来克服它。在哪里可以从TransportContextHolder.getTransportContext().getConnection()中提取CommonsHttpConnection

    【讨论】:

    • 你好,我也有这种需求。 TransportContextHolder.getTransportContext().getConnection() 正在给我 HTTPUrlConnection.. 我可以知道如何继续吗?
    • @Manoj 我希望将其视为一个新的单独问题。谢谢
    • 好吧,Artem,我找到了答案。我们可以得到 HTTPUrlConnection.getConnection().setRequestProperty() 就可以了。
    猜你喜欢
    • 2021-12-24
    • 1970-01-01
    • 1970-01-01
    • 2015-04-10
    • 1970-01-01
    • 1970-01-01
    • 2014-02-20
    • 2016-10-12
    • 2012-01-25
    相关资源
    最近更新 更多