开发者

Debugging GroovyWS. Get the actual generated XML

I'm using GroovyWS in a Grails app to connect to an external SOAP server.

I'd like to see the 开发者_运维问答actual XML that is generated by GroovyWS since I'm getting errors without any useful information.

I know I can use wireshark or something similar, but there really should be an easier way.

Printing the object just prints the Java Object@... string.


GroovyWS uses Apache CXF internally, so you should be able to use its logging interceptors to do the trick. Cutting and pasting the temperature example from the GroovyWS docs, the following test script prints both the request and response SOAP messages:

@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"

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜