Created
August 22, 2016 17:31
-
-
Save magnuspalmer/c22f85d1a1653308f3576dc3ea2bd4ca to your computer and use it in GitHub Desktop.
Simple Groovy SOAP request using wslite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='1.1.0') | |
import wslite.soap.* | |
import groovy.xml.* | |
def client = new SOAPClient('http://www.webservicex.net/globalweather.asmx') | |
String city = 'Stockholm' | |
String country = 'Sweden' | |
def weatherResponse = client.send(){ | |
version SOAPVersion.V1_2 // SOAPVersion.V1_1 is default | |
soapNamespacePrefix "soap12" // "soap-env" is default | |
envelopeAttributes "xmlns:ns1":"http://www.webserviceX.NET" | |
header {} | |
body { | |
'ns1:GetWeather' { | |
'ns1:CityName'(city) | |
'ns1:CountryName'(country) | |
} | |
} | |
} | |
println weatherResponse.body |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-16"?> | |
<CurrentWeather> | |
<Location>Stockholm / Bromma, Sweden (ESSB) 59-21N 017-57E 14M</Location> | |
<Time>Aug 22, 2016 - 01:20 PM EDT / 2016.08.22 1720 UTC</Time> | |
<Wind> from the S (180 degrees) at 10 MPH (9 KT):0</Wind> | |
<Visibility> greater than 7 mile(s):0</Visibility> | |
<Temperature> 68 F (20 C)</Temperature> | |
<DewPoint> 53 F (12 C)</DewPoint> | |
<RelativeHumidity> 59%</RelativeHumidity> | |
<Pressure> 30.06 in. Hg (1018 hPa)</Pressure> | |
<Status>Success</Status> | |
</CurrentWeather> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment