Java 如何从JAXRS MessageContext获取发布的xml?

Java 如何从JAXRS MessageContext获取发布的xml?,java,http,cxf,jax-rs,Java,Http,Cxf,Jax Rs,我试图从JAXRS传递的MessageContext中获取XML。有没有办法直接从MessageContext对象中包含的方法获取XML的内容 我认为这会奏效: @PUT @Path ("/") @Consumes ({ "application/json", "application/xml" }) @Produces ({ "text/html", "application/json", "application/xml" }) public Response update(@Context

我试图从JAXRS传递的MessageContext中获取XML。有没有办法直接从MessageContext对象中包含的方法获取XML的内容

我认为这会奏效:

@PUT
@Path ("/")
@Consumes ({ "application/json", "application/xml" })
@Produces ({ "text/html", "application/json", "application/xml" })
public Response update(@Context MessageContext mc) {
    mc.getHttpServletRequest().get....
    // unsure of how to grab the actual xml from the request...
但是里面的信息不是我想要的。我只需要在请求中推送的XML


有用于记录拦截器的选项,但我不想只记录请求,我想实际使用XML对其进行一些操作。

您可以使用来自的getRequest。然后,您只需要将请求转换为字符串,如中所述,

我分别尝试了bufferedreader、inputstream和getParameter,它们似乎返回空值。或者消息为空,但此时肯定不应该返回。否则我为什么要传递消息上下文?