I want to do a POST request to a web service in grails, but it seems like the available JAVA solutions are on a very low abstraction level, like building the POST request myself (here is the sample I found: http://www.exampledepot.com/egs/java.net/Post.html)
Is there a better solution for this problem in Grails? I searched through the manuals and other stuff, but did not really find something. Just wondering, because normally I did not see much code like this wen developing Grails.
So if there is no other solution, then this will also be O.K., abstracted by me and hidden somewhere in our libraries, but I guess there is a better solution somewhere.
There's the Groovy-specific HTTPBuilder, which provides a nice interface built on the Apache HTTPClient. It even has a REST client, if that's appropriate for the service your are trying to access. There's even a Grails plugin to wrap that all up for you.
If the service is REST-enabled there are a range of Java projects and APIs that can simplify things.
On the other hand, if the web service you are trying to access is SOAP-based, you can leverage GroovyWS, which is also wrapped in a Grails plugin available here.
I've just listed a bunch of options. What will work best depends a lot on the service you are trying to connect to. I'd recommend starting with a pre-built Grails plugin and only branching out if you find it doesn't meet your needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With