Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails and consume SOAP webservice

Being fairly new to Grails i was wondering what people use to consume a webservice in Grails projects. So the client side of the system? Any recommendations? I see people using GroovyWS, Spring-WS etc.. What is a good and easy on to use?

like image 561
Marco Avatar asked Jan 23 '26 08:01

Marco


2 Answers

GroovyWS is very easy to use and has great documentation I would definitely recommend it.

like image 138
atodd Avatar answered Jan 25 '26 21:01

atodd


Using Grails CXF plugin here. Needed:

  1. classloader workaround - DynamicClientFactoryit changed a current classloader;
  2. and to code WS invocations by hand.

Besides that, the consumer code is pretty slim.

Edit: sorry, no more then this, and I'm not sure I'm not breaking and NDA yet:

#1:

def arrayOfLong = objectFactory.createArrayOfLong(XXX, ids)
result = client.invoke(methodName, arrayOfLong as Object[])

#2:

def dcf = DynamicClientFactory.newInstance()
def classLoader = Thread.currentThread().getContextClassLoader()

// create a WS client
// and assign end point address to it
def client = dcf.createClient(WSDL_URL, classLoader)
client.conduit.target.address.setValue(endpointUrl)

// reacquire classloader because 'createClient' changes it
def changedClassLoader = Thread.currentThread().getContextClassLoader()
def objectFactory = changedClassLoader.
    loadClass(FACTORY_CLASS_NAME).newInstance()
like image 31
Victor Sergienko Avatar answered Jan 25 '26 20:01

Victor Sergienko