2010-01-18 14 views
2

我在Grails應用程序中使用GroovyWS連接到外部SOAP服務器。調試GroovyWS。獲取實際生成的XML

我想看看由GroovyWS生成的實際XML,因爲我得到的錯誤沒有任何有用的信息。

我知道我可以使用wireshark或類似的東西,但真的應該有一個更簡單的方法。

打印對象只是打印Java Object @ ...字符串。

回答

1

GroovyWS在內部使用Apache CXF,因此您應該可以使用它的日誌攔截器來實現這個功能。切割和從GroovyWS文檔,下面的測試腳本的打印請求和響應SOAP消息粘貼溫度例如:

@Grab(group='org.codehaus.groovy.modules', module='groovyws', version='0.5.2') 
import groovyx.net.ws.WSClient 

import org.apache.cxf.interceptor.LoggingInInterceptor 
import org.apache.cxf.interceptor.LoggingOutInterceptor 

proxy = new WSClient("http://www.w3schools.com/webservices/tempconvert.asmx?WSDL", this.class.classLoader) 
proxy.initialize() 

println proxy.client.outInterceptors.add(new LoggingOutInterceptor()) 
println proxy.client.inInterceptors.add(new LoggingInInterceptor()) 
result = proxy.CelsiusToFahrenheit(0) 
println "You are probably freezing at ${result} degrees Farhenheit" 

參見http://cxf.apache.org/docs/debugging-and-logging.html