Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用spring集成调用restful Web服务?_Java_Spring_Spring Integration - Fatal编程技术网

Java 如何使用spring集成调用restful Web服务?

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>

我不熟悉spring集成。要进行RESTWebService调用,我有以下配置

<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基本身份验证”将提供几个示例,包括