这是我使用jax-rs客户机执行请求的代码:
private Client client;
private static final int TIMEOUT = 8000;
@PostConstruct
public void init() {
client = ClientBuilder.newBuilder()
.readTimeout(TIMEOUT, TimeUnit.MILLISECONDS)
.connectTimeout(TIMEOUT, TimeUnit.MILLISECONDS)
.build();
}……
final String resource = "/some-endpoint/{id}/securityinfo";
final String path = url + resource;
final WebTarget target = client
.target(path)
.resolveTemplate("id", email);
final var form = new Form().param("mail", email);
final Response response = target
.request()
.post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED));
if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
throw new MyException(response.readEntity(String.class));
}我收到错误:
javax.ws.rs.ProcessingException: RESTEASY004655:无法调用请求: javax.ws.rs.ProcessingException: RESTEASY003215:无法为内容类型的应用程序/x-www-form-urlencoded类型: javax.ws.rs.core.Form找到编写器
这种情况只发生在表单内容类型请求中,因为json支持正常工作。
编辑
这些是所使用的依赖关系:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-oracle</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>发布于 2022-03-03 16:28:56
您是否尝试过使用(https://docs.oracle.com/javaee/7/api/javax/ws/rs/client/Entity.html#form-javax.ws.rs.core.Form-):
Entity.form(form);我不确定它能解决这个问题,因为它只是你所拥有的东西的简写。但我会试一试。
为了更容易地找到解决方案,可以共享您在项目中使用的依赖项。
https://stackoverflow.com/questions/71335836
复制相似问题