maven项目使用openfeign,从此和httpClient说拜拜
pom.xml:
<dependency> <groupId>io.github.openfeign</groupId> <artifactId>feign-jaxb</artifactId> <version>9.7.0</version> </dependency> <dependency> <groupId>io.github.openfeign</groupId> <artifactId>feign-jackson</artifactId> <version>9.7.0</version> </dependency> <dependency> <groupId>io.github.openfeign</groupId> <artifactId>feign-core</artifactId> <version>9.7.0</version> </dependency>
响应头实体类:
/** * esb返回结果 * * @author shengyang.xiao */ public class EsbRequest<REQUEST_DATA> { /** * 响应头 */ @JsonProperty("EsbReqHeader") private EsbReqHeader resHeader; /** * 响应数据集 */ @JsonProperty("EsbReqData") private List<REQUEST_DATA> reqData; public EsbReqHeader getResHeader() { return resHeader; } public void setResHeader(EsbReqHeader resHeader) { this.resHeader = resHeader; } public List<REQUEST_DATA> getReqData() { return reqData; } public void setReqData(List<REQUEST_DATA> reqData) { this.reqData = reqData; } }
Client:
/** * esb服务客户端 * * @author shengyang.xiao * @since 2019-08-20 16:08 */ public interface EsbClient { /** * 从SSO获取当前系统的帐户信息 * * @param request * @return EsbResponse<EmployeeDto> * @author shengyang.xiao * @since 2019-08-20 16:08 */ @RequestLine("POST ") @Headers("Content-Type: application/json") EsbResponse<EmployeeDto> queryAccountByResCodeFromSso(EsbRequest<QueryAccountRequestData> request); }