Apache CXF jaxrs 客户端在执行请求时不包含标头

时间:2021-02-26 03:33:28

标签: spring-boot jax-rs

我在 SpringBoot 项目中使用 Apache CXF 来调用 API。(我可以使用 RestTemplate 进行调用,但我们使用的客户端库限制我们使用 Apache CXF)

我为 jaxrs 客户端创建了一个 bean,如下所示(为了便于理解,代码已简化),正如您所看到的,在创建 bean 时添加了标头。当我使用此客户端调用 API 时,请求因缺少标头而失败(已通过使用 wireshark 验证)。

@Bean
public ConfigurationServiceClient createClient() {
    ConfigurationServiceClient client = JAXRSClientFactory.create(apiUrl, ConfigurationServiceClient.class, providers, true);

    Client internalClient = WebClient.client(client);
    internalClient.header("apigatewayValidated", Boolean.TRUE);
    internalClient.header("sm_userdn", distinguishedName);

    return client;
}

但是如果我按需创建 jaxrs 客户端(而不是作为 spring bean),则 API 调用有效。

我调试了代码,我可以看到创建 bean 时包含在 jaxrs 客户端中的标头,但没有通过实际调用 API 的线程传递。

我在创建客户端时是否缺少任何其他参数?

0 个答案:

没有答案
相关问题