Wslite plugin
Dependency :
compile ":wslite:0.7.2.0"Custom repositories :
mavenRepo "https://oss.sonatype.org/content/groups/public/"
Summary
This plugin brings the power of https://github.com/jwagenleitner/groovy-wslite library to your
Grails app. Thanks to Andres Almiray to provided code at https://github.com/griffon/griffon-wslite-plugin!
Installation
grails install-plugin wslite
Description
Usage
The plugin will inject the following dynamic methods:- `withRest(Map params, Closure stmts)` - executes stmts using a RESTClient
- `withHttp(Map params, Closure stmts)` - executes stmts using an HTTPClient
- `withSoap(Map params, Closure stmts)` - executes stmts using a SOPAClient
- connectTimeout
- readTimeout
- followRedirects
- useCaches
- sslTrustAllCerts
- sslTrustStoreFile
- sslTrustStorePassword
- proxy
- httpConnectionFactory
- authorization
Samples
withRest(url: 'http://api.twitter.com/1/') {
def response = get(path: '/users/show.json', query: [screen_name: 'jwagenleitner', include_entities: true])
println response.json
}withSoap(serviceURL: 'http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx') {
def response = send(SOAPAction: 'http://www.27seconds.com/Holidays/US/Dates/GetMothersDay') {
body {
GetMothersDay(xmlns: 'http://www.27seconds.com/Holidays/US/Dates/') {
year(2011)
}
}
} println response.GetMothersDayResponse.GetMothersDayResult.text()
}withSoap(serviceURL: 'http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx') {
def response = send {
body {
GetMothersDay(xmlns: 'http://www.27seconds.com/Holidays/US/Dates/') {
year(2011)
}
}
} println response.GetMothersDayResponse.GetMothersDayResult.text()
}withSoap(serviceURL: 'http://www.w3schools.com/webservices/tempconvert.asmx') {
def response = send(SOAPAction: 'http://tempuri.org/CelsiusToFahrenheit') {
body {
CelsiusToFahrenheit(xmlns: 'http://tempuri.org/') {
Celsius("0")
}
}
} def result = response.CelsiusToFahrenheitResponse.CelsiusToFahrenheitResult.text()
println "You are probably freezing at ${result} degrees Farhenheit"
}withSoap(serviceURL: 'http://www.w3schools.com/webservices/tempconvert.asmx') {
def response = send {
body {
CelsiusToFahrenheit(xmlns: 'http://tempuri.org/') {
Celsius(0)
}
}
} def result = response.CelsiusToFahrenheitResponse.CelsiusToFahrenheitResult.text()
println "You are probably freezing at ${result} degrees Farhenheit"
}