Question

I just need a SOAP client to make remote calls, but I'm a bit of a Groovy noob. According to the Groovy documentation, the standard Groovy SOAP library is deprecated. Instead, the docs point you to a newer library: GroovyWS.

Unfortunately, GroovyWS has a warning that says the project is dormant and it then points you to Groovy WSLite.

Groovy WSLite actually still appears to be under active development, but not very 'Groovy-ish' compared to the previous 2 libraries. Is wslite what everyone is using?

Était-ce utile?

La solution

I think you would find both GroovyWS and groovy-wslite (and HTTP Builder) are in use as Groovy SOAP client libraries in projects and the decision was probably one of which one worked and which one had the API/approach the user preferred (in that order).

My advice would be to give GroovyWS a try if you like the API it provides and its ability to proxy a WSDL document and see if it works for the services you need to interact with. Things have not changed much in the SOAP world so I would not worry too much about how recently it has been updated. If it works then you are done, if you experience some issues that you are not able to readily find help for then I would try the alternatives.

groovy-wslite (disclaimer: I'm the author) aims to provide a lightweight (in terms of dependencies) alternative that trades the convenience of WSDL parsing/proxying for making it easier to have more control over the resulting soap call without having to dig deep into the internals of some underlying Java framework like CXF. Some prefer having the additional features of a library built on top of a framework like this while others may prefer the simplicity of the other approach.

The thing that makes Groovy so great is how easy it is to integrate with Java. So, as others have already pointed out, you can integrate with Java web service clients like Spring WS, CXF, and JAX-WS pretty easily.

Autres conseils

I'd stay way clear of groovyws, it sucks. After looking around I finally chose the solution of using spring web services and contract-driven web services.

The client instantiates command objects with a toXml() method that generates the soap request XML. Then use the WebServiceTemplate to sendToEndpoint.

For the server, we use spring web services endpoints. Parsing the incoming xml is child's play, and you don't need to marshal the XML into an object, as the GPathResult resulting from an XmlSlurper is totally manageable. Our server runs on top of grails, so we took advantage of the springws grails plugin, making the creation of Endpoints even easier.

There is one caveat though. The springws plugin for grails is out of date. Spring web services is now version 2.x and springws plugin comes with 1.4.x i think. However, it is very easy to use without the plugin, and I think that upgrading the plugin to the newer api is not hard.

Also, if you want to do MTOM, springws gets a little more complicated, because you need to dig deeper into the message handling. I was able to do some pretty advanced ws-security stuff with spring web services however, no problem.

Otherwise i would use cxf (handles MTOM nicely), if you want to stick with jax-ws et al. The overhea is probably higher, because all the dynamically generated proxies and pojos. Also, it is not contract-driven, which is a big plus for us.

http://predic8.com/groovy-web-services-jax-ws.htm

http://cxf.apache.org/docs/how-do-i-develop-a-client.html

Looks like you have done the homework yourslef! Groovy WS Lite seems to be currently working one. If you want to see spring-ws in action using Groovy, then here is a test suite project I had created in github.

Or you can use JSON instead. SOAP is quite antiquated. The links above for groovy documentation and GroovyWS go nowhere

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top