![](/img/trans.png)
[英]How to unmarshall xml from Http Post Rest Web Service with Jaxb using spring mvc?
[英]how to automatically log request and response xml in rest web service using JAXB?
我正在用Java开发其他Web服务。 我需要使用JAXB在rest Web服务中自动记录请求和响应xml。
以下是我的休息服务。
@POST
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
@Path("/xmlCall")
@Override
public XmlCallOutput postXmlCall(Xmlcall xmlCall){
return xmlCallInService.acceptXmlCallData(xmlCall);
}
在这里,我想以xml形式记录Xmlcall和XmlCallOutput对象。 有没有直接的方法可以做到这一点?
您可以在转换对象之前或之后记录请求/响应。 这并不像您期望的那么琐碎,关键是实现一些类似这样的接口:
public class PrettyPrinterLoggingFilter implements ContainerRequestFilter, ContainerResponseFilter, WriterInterceptor {
..
}
并插入现有的基础架构。 我已经写了一个小库来做这个例子。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.