2

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.

Reverend Gonzo
  • 39,701
  • 6
  • 59
  • 77

1 Answers1

1

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

Unk
  • 1,103
  • 6
  • 11