【问题标题】:How to call restful webservice using spring integration?如何使用spring集成调用restful web服务?
【发布时间】:2012-12-07 18:38:53
【问题描述】:

我是 Spring 集成的新手。要进行休息网络服务调用,我有以下配置。

<int-http:outbound-gateway
    url="#{appProperties['rootUrl']}#{appProperties['myMethod']}"
    request-channel="myRequestChannel" reply-channel="myResponseChannel" >
</int-http:outbound-gateway>

但我还应该传递身份验证信息(用户名和密码)来进行网络服务调用。如何通过http:outbound-gateway发送认证信息?

【问题讨论】:

    标签: java spring spring-integration


    【解决方案1】:

    您必须使用自定义 ClientHttpRequestFactory 并使用 request-factory 属性将其提供给适配器。

    要么将CommonsClientHttpRequestFactory 与自定义HttpClient 结合使用,要么将SimpleClientHttpRequestFactory 子类化并覆盖prepareConnection 方法以添加凭据。

    谷歌搜索“resttemplate basic authentication”将提供几个示例,包括http://blog.mitemitreski.com/2012/03/basic-authentication-with-resttemplate.html

    【讨论】:

      猜你喜欢
      • 2017-07-08
      • 2014-02-20
      • 1970-01-01
      • 2013-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-05
      • 1970-01-01
      相关资源
      最近更新 更多