State of WS clients in Grails 1.1
The following is just a posting from a few days of digging. Hopefully it can help others. I am not a WS expert at all, just a developer trying to get a client to work, that said, if everything is mis-stated below, please correct me.
I love groovyws. Great idea, Great implementation. However, if you use it, you have to reinitialize the proxy on every web request. This can be real resource hog. The problem appears to lie with the apache cxf dynamic libraries. https://issues.apache.org/jira/browse/CXF-1203 While this issue is old, it describes exactly the problem that I have been experiencing. It would be nice if that bug is fixed and we can load a service once and reuse it for multiple calls.
Without the dynamic client at our disposal, we are limited to generating a client from wsdl using metro/xfire/apache cxf tools
Can't use xfire generated client in grails 1.1. You can certainly implement xfire services, but not clients. If you do this, you will go into "jarmagedon " Just do a search on "java.lang.LinkageError: loader constraints violated when linking javax/xml/namespace/QName" It's not so simple as just replacing a couple of jars.
Last options are metro & apachecxf. Found this blog http://wiki.callistaenterprise.se/pages/viewrecentblogposts.action?key=C...
To summarize, use metro client. Using metro also jives with some of posts on this mailing list.
It am starting with metro now.
HTH

Comments
Hi, I also had the same
Hi,
I also had the same issue.
I was calling the proxy.initialize() on every call.
Now by calling this only once and reusing the initialized proxy I have have reduced my WS call's to less than a second!
Thanks...
Jay
This may be help (GroovyWS)
This may be help (GroovyWS)
I experienced that GroovyWS issue too. So as a work-around, I made a separate groovy class which offers methods for the WS calls I want to use. The class is realized as singleton and its "getInstance" method initializes the proxy (which is a member of the class), but only once. Looks like this:
...
def proxy = null
static MyWSClass instance = null
private MyWSClass(){
super()
}
static String wsdl = "http://somwhere/someWSDL?wsdl"
public static MyWSClass getInstance(){
if (!instance){
instance = new WSAccountMgmt()
instance.proxy =
new WSClient(wsdl, instance.class.classLoader)
instance.proxy.initialize()
}
return instance
}
public String getSomething(Sting input){
def result = proxy.getSomething(input)?:null
...
Hence the proxy is initialized only once - which of course may take some time. But after that it is "recycled" -> speeds up the process.
And if you invoke "MyWSClass.getInstance()" in "Bootstrap.groovy", the initialization will be done on start-up - once the application is running, the user will not experience the slow-down of the initialization.
That's just my suggestion. Maybe it works for you too.
Timo
(sorry for my english - I am not a native speaker)
Post new comment