Java 如何使用spring集成调用restful Web服务?
我不熟悉spring集成。要进行RESTWebService调用,我有以下配置Java 如何使用spring集成调用restful Web服务?,java,spring,spring-integration,Java,Spring,Spring Integration,我不熟悉spring集成。要进行RESTWebService调用,我有以下配置 <int-http:outbound-gateway url="#{appProperties['rootUrl']}#{appProperties['myMethod']}" request-channel="myRequestChannel" reply-channel="myResponseChannel" > </int-http:outbound-gateway>
<int-http:outbound-gateway
url="#{appProperties['rootUrl']}#{appProperties['myMethod']}"
request-channel="myRequestChannel" reply-channel="myResponseChannel" >
</int-http:outbound-gateway>
但我也应该传递身份验证信息(用户名和密码)来进行webservice调用。如何通过
http:outbound gateway
发送身份验证信息?您必须使用自定义ClientHttpRequestFactory,并使用请求工厂属性将其提供给适配器
将CommonClientHttpPrequestFactory
与自定义的HttpClient
一起使用,或者将SimpleClientHttpRequestFactory
子类化,并覆盖prepareConnection
方法以添加凭据
谷歌搜索“resttemplate基本身份验证”将提供几个示例,包括