quarkus - Quarkus RestClient 从重定向获得响应
问题描述
我正在使用Quarkus Rest Client对外部 API 服务执行 GET 请求。但是,此服务不会直接返回我需要接收的资源 (XML),但它会重定向到另一个返回资源的 API 服务。
当我尝试导航到向 API 服务询问资源的路径时(即 localhost:8080/hello),我被重定向到包含资源的页面,而不是接收和处理它。
在请求之后放置断点,表明请求之后的代码部分永远不会到达。这是端点的代码:
@Path("/hello")
public class GreetingResource {
@Inject
@RestClient
MyService myService;
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
myService.performGet();
return "you are here"; // breakpoint here, it is never reached
}
}
这是 MyService 的代码:
@Path("/..")
@RegisterRestClient(configKey="key")
public interface MyService {
@GET
@Path("/..")
@Produces(MediaType.TEXT_XML)
String performGet(@QueryParam("c") String c, @QueryParam("d") String d);
}
我试图添加配置key/mp-rest/followRedirects=true
,但我仍然遇到同样的问题。此外,使用没有重定向的路径,一切正常。
使用本机 HttpURLConnection 也可以正常工作,但是,由于我使用的是 Quarkus,我想改用它的功能。
解决方案
推荐阅读
- node.js - 连接到 Mailchimp api 时的正确错误处理
- python - 如何在 Python 中删除超过 5 分钟的 wav 文件
- .net - 删除特定标记后的 HTML 标记
- python - ImportError:无法从“bokeh.core.properties”(C:\ProgramData\Anaconda3\lib\site-packages\bokeh\core\properties.py)导入名称“Nullable”
- java - 如何检查 Docker 容器中的应用程序是否忽略 Java 内存选项?
- python - asyncio.Queue 被 1 个协程添加到队列中,1 个协程从队列中获取
- javascript - 当位于页面的特定部分时,我需要使用 JavaScript 突出显示导航栏中与其相关的按钮
- c++ - 两个类与另一个类的成员函数交朋友
- python - 在 TensorFlow WHILE 训练中添加检查点
- python - 当我使用请求模块时,python 给我一个“套接字错误”