我从客户端收到一个请求,该请求返回一个SendRequest-Object,该对象具有HttpMethod,要发送的路径和数据。现在,我想根据获取到API的对象来发送请求。
发送后,我将收到回复。
现在的问题是如何发送有效载荷并接收响应。
@Bean
public IntegrationFlow httpPostSendRawData() {
return IntegrationFlows.from(
Http.inboundGateway("/api/data/send")
.requestMapping(r -> r.methods(HttpMethod.POST))
.statusCodeExpression(dataParser().parseExpression("T(org.springframework.http.HttpStatus).BAD_REQUEST"))
.requestPayloadType(ResolvableType.forClass(DataSend.class))
.crossOrigin(cors -> cors.origin("*"))
.headerMapper(dataHeaderMapper())
)
.channel("http.data.send.channel")
.handle("rawDataEndpoint", "send")
.transform(/* here i have some transformations*/)
.handle(Http.outboundGateway((Message<SendRequest> r)->r.getPayload().getPath())
.httpMethod(/* Here I would like to get the Method of SendRequest*/)
//add payload
.extractPayload(true))
.get();
不清楚您是什么人SendRequest
,但是的想法与您对的想法method
完全相同url
:
.httpMethodFunction((Message<SendRequest> r)->r.getPayload().getMethod())
虽然,因为你希望有一些萃取请求主体,你需要做的是,在事先在transform()
和移动值url
,并method
在头文件。:中没有任何有效负载提取Http.outboundGateway
:它将整个请求有效负载作为HTTP请求主体的实体来处理。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句