Jersey UniformInterfaceException trying to proxy to REST POST service

蹲街弑〆低调 提交于 2019-12-05 13:06:43

UniformInterfaceException is just a catch-all exception with a poor name (it's named this because it's an exception that provides a uniform interface, no matter the error). It's basically an IOException thrown by anything in Jersey. The actual error is the 406 Unacceptable:

The requested resource is only capable of generating content not acceptable according to the Accept headers sent in the request.

Here you're saying that you accept MediaType.APPLICATION_FORM_URLENCODED:

String returnValue = service.accept(MediaType.APPLICATION_FORM_URLENCODED).post(String.class, form);

But your service produces MediaType.APPLICATION_XML:

@Produces(MediaType.APPLICATION_XML)

Since your server can't produce any content that the client says it will accept, it returns a 406 error.

Most likely, you're meaning to set WebResource.type, not accept:

String returnValue = service.type(MediaType.APPLICATION_FORM_URLENCODED).post(String.class, form);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!