0
我想用我从数据库中获取的信息构建一个Response对象。我取回的信息是在更改对象:试图为Java REST风格的服务构建Response对象
的change.getDocument()
回来的是:
{"testSolution":false,"solutionId":333,"clientId":4018593,"firewall":false,"pod":"pod3.dmy3","networkPolicy":{"speed":"1","subnets":{"nat":{"vlan":3004,"cidr":["110.168.0.0/24"]},"private":{"vlan":3004,"cidr":["15.10.1.128/25"]}}}}
所以我创造这样的回应:
return Response.status(422).location(location).entity(changeRequest).build();
在单元测试中我做到这一点:
String responseJson = response.readEntity(String.class);
System.out.println("The response is: " + responseJson);
为了测试,但我得到这个结果:
The response is: {"object_id" : 333,"object_type" : "class com.entities.Solution", "operation" : "", "revision" : 0, "remote_user" : "", "remote_host" : "", "created" : "", "published" : "", "comment" : "HTTP Status Code 422", "error" : "HTTP Status Code 422, there is a pending change request for this Solution. Replying with pending ChangeRequest", "document" : {} }
一切都如预期的那样,但文档节点不包含任何信息。我是否正确构建Response对象?
你有错误400? – alexvetter