简体   繁体   English

JAX-RS从发布响应java中检索Entity参数

[英]JAX-RS retrieve Entity parameter from post Response java

I am trying to retrieve entities from body response of a POST request 我正在尝试从POST请求的正文响应中检索实体

    Client client = ClientBuilder.newClient(new ClientConfig());
    Response response = client.target(url)
            .request(MediaType.APPLICATION_JSON)
            .post(Entity.entity(form,MediaType.APPLICATION_JSON), Response.class);
    Log.trackingResponse(url, response);`

request is 200 OK, parameters I want to retrieve exist, I can see them while debugging: request是200 OK,我要检索的参数存在,调试时可以看到它们:

在此处输入图片说明

My problem is I can not access these parameters. 我的问题是我无法访问这些参数。

I tried the following solution but it was not successful: 我尝试了以下解决方案,但未成功:

Map<String, Object> jsonResponse = clientResponse.readEntity(Map.class);

MessageBodyProviderNotFoundException MessageBodyProviderNotFoundException

Order order = response.readEntity(Order.class); 

Order being a custom class with Jacksonannotation, MessageBodyProviderNotFoundException 订单是带有Jacksonannotation,MessageBodyProviderNotFoundException的自定义类

 String jsonResponse = clientResponse.readEntity(String.class);

returns < ! 返回<! DOCTYPE html PUBLIC .... the whote html code, but not my parameters DOCTYPE html PUBLIC .... whote html代码,但不是我的参数

My maven has the correc jackson depedency. 我的专家有杰克逊矫正病。

Any idea ? 任何想法 ? Thanks 谢谢

These parameters are part of the request you sent, not the response. 这些参数是您发送的请求的一部分,而不是响应的一部分。 They are members of the form you sent in the request entity: 它们是您在请求实体中发送的form成员:

.post(Entity.entity(form,MediaType.APPLICATION_JSON), Response.class);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM