java-如何使用Spring集成调用静态Web服务?

前端之家收集整理的这篇文章主要介绍了java-如何使用Spring集成调用静态Web服务? 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_404_0@

我是春季集成的新手.拨打一个休息的网络服务电话,我有以下配置.

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

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

最佳答案
您必须使用自定义ClientHttpRequestFactory并使用request-factory属性将其提供给适配器.

可以将CommonsClientHttpRequestFactory与自定义HttpClient一起使用,或者将SimpleClientHttpRequestFactory子类化并重写prepareConnection方法添加凭据.

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

原文链接:https://www.f2er.com/spring/531871.html

猜你在找的Spring相关文章