关于feign调用的时候,动态传url ,以及自定义head

 1 package com.fdd.op.autoconfigure.http.client.service;
 2 
 3 import com.alibaba.fastjson.JSONObject;
 4 import com.fdd.op.autoconfigure.http.feign.FeignHttpClientConfiguration;
 5 import org.springframework.cloud.openfeign.FeignClient;
 6 import org.springframework.web.bind.annotation.PostMapping;
 7 import org.springframework.web.bind.annotation.RequestBody;
 8 import org.springframework.web.bind.annotation.RequestHeader;
 9 
10 import java.net.URI;
11 
12 
13 /**
14  * API 回调  feign
15  * url = "EMPTY"  随便填都行,会被下方的参数URI 覆盖
16  *
17  * @author kuangql
18  */
19 @FeignClient(name = "apiServiceClient", url = "EMPTY", configuration = FeignHttpClientConfiguration.class)
20 public interface ApiServiceClient {
21 
22 
23     /**
24      * api 回调
25      *
26      * @param url         动态地址
27      * @param jsonObject  json 回调值
28      * @param opAppId     head
29      * @param opNonce     head
30      * @param opTimestamp head
31      * @param opSignType  head
32      * @param opVersion   head
33      * @param opSign      head
34      * @return result
35      */
36     @PostMapping(headers = {"Content-Type: application/json"})
37     String sendApiNotify(URI url, @RequestBody JSONObject jsonObject,
38                          @RequestHeader("opAppId") String opAppId, @RequestHeader("opNonce") String opNonce,
39                          @RequestHeader("opTimestamp") String opTimestamp, @RequestHeader("opSignType") String opSignType,
40                          @RequestHeader("opVersion") String opVersion, @RequestHeader("opSign") String opSign
41     );
42 
43 }

 

 

 测试过很多注解传header,但是会翻车。

 需要设置超时,重试次数,参考。

https://blog.csdn.net/kysmkj/article/details/89672952

 

posted @ 2021-09-13 19:33  夏风中的Young_Uncle  阅读(1939)  评论(0编辑  收藏  举报