转储原始XML以调试Grails REST调用 [英] Dump raw XML to debug Grails REST calls

查看:96
本文介绍了转储原始XML以调试Grails REST调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要转储原始XML以解决Grails 1.2应用程序中与数据相关的问题。在UrlMappings中,我们有parseRequest:true。以下没有得到我想要的,还有其他选择吗?请注意,我们在生产机器上需要这样的设置,所以适合开发的小提琴手或类似的基于代理的解决方案不是一种选择

We need to dump the raw XML for troubleshooting data dependant issues on a Grails 1.2 app. In the UrlMappings we have "parseRequest:true". The following does not get me what I'm looking for, any other options? Note that we need this on a production machine, so fiddler or similar proxy based solutions suitable for development are not an option

def beforeInterceptor = {
    println "#"*99
    println "Executing action $actionName with params=$params"
    println request.inputStream.dump()
    //println request.inputStream.text // java.io.IOException: Stream closed
    println request.XML
}


推荐答案

如果我没有记错,当你做request.XML时,你应该会收到一个XmlSlurper对象。所以这个应该得到你想要的。

If I remember correctly, when you do request.XML you should receive an XmlSlurper object. So this should get what you want.

def beforeInterceptor = {
   def xml = request.XML
   def xmlString = new XmlNodePrinter(new PrintWriter(new StringWriter())).print(xml)
}

这篇关于转储原始XML以调试Grails REST调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆