import groovy.util.XmlSlurper
 
URL url = new URL("https://servis.apinizer.com/SoapExampleService.svc")
HttpURLConnection conn = url.openConnection()
conn.setDoOutput(true)
var password='''<![CDATA[ ]]>'''
 
conn.setRequestProperty( "SOAPAction", "http://tempuri.org/SoapExampleService/GetToken" )
conn.setRequestProperty( "Content-Type", "text/xml" )
var xml="<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org/\">   <soapenv:Header/>   <soapenv:Body>      <tem:GetToken>         <tem:userName>kullaniciAdi</tem:userName>         <tem:password>"+password+"</tem:password>      </tem:GetToken>   </soapenv:Body></soapenv:Envelope>";
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream())
wr.write(xml)
wr.close()
  
InputStream  responseStream = conn.getInputStream()
String response = responseStream.getText("utf-8")
responseStream.close()
 
def Envelope = new XmlSlurper().parseText(response)
requestHeaderMapToTargetAPI.put( "TokenId", Envelope.Body.GetTokenResponse.GetTokenResult.text() )
GROOVY