Forum Discussion
max1965
13 years agoContributor
I fix the problem with get http. I use the following groovy script to send the get request:
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.Method.*
import static groovyx.net.http.ContentType.*
def Indirizzo_F5_FE = context.expand( '${#Global#Indirizzo_F5_FE}' )
def Porta_F5_FE = context.expand( '${#Global#Porta_F5_FE}' )
def props = testRunner.testCase.getTestStepByName( "Properties" )
def cli = props.getPropertyValue("cli");
def ippresenza = props.getPropertyValue("ippresenza");
def http = new HTTPBuilder( "http://${Indirizzo_F5_FE}:${Porta_F5_FE}/AuthInterface/acctRequest?cli=${cli}&ip=${ippresenza}&sessionType=APT&msgType=START" )
http.request(GET,TEXT){ req ->
headers.'Connection' = 'Keep-Alive'
headers.'User-Agent' = 'SoapUI 4.5.1'
response.success = { resp, reader ->
assert resp.status == 200
ret = reader.getText()
}
}
props.setPropertyValue("answer", ret);
and the following groovy script to check the response:
import com.eviware.soapui.support.xml.XmlUtils
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def props = testRunner.testCase.getTestStepByName( "Properties" )
def answer = props.getPropertyValue("answer");
xmlBody = new XmlParser().parseText(answer)
errorCode = xmlBody.@errorCode
def cli = props.getPropertyValue("cli");
if ( errorCode != "5000" )
{
log.info("ACCT START UMA $cli - wrong errorCode: $errorCode")
testRunner.fail( "errorCode" )
}
Now I try to send a post http request, but I'm not able to build the correct request to send the following post boby:
input=<?xml version="1.0" encoding="UTF-8"?><UNCMARRequest xmlns="UdbCxInterface"xmlns:xsi="http://www.w3.org/2001 /XMLSchema-instance"xsi:schemaLocation="UdbCxInterface C:\UNCMARRequest.xsd"><username>${id}</username><resourceIp>${ippresenza}</resourceIp><msgType>REGISTER</msgType><methodType>UserProfile</methodType><version>${versioneCx}</version><uncId>TIMUNC1</uncId><olo>TIM</olo></UNCMARRequest>
Someone could help me ? Thanks.
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.Method.*
import static groovyx.net.http.ContentType.*
def Indirizzo_F5_FE = context.expand( '${#Global#Indirizzo_F5_FE}' )
def Porta_F5_FE = context.expand( '${#Global#Porta_F5_FE}' )
def props = testRunner.testCase.getTestStepByName( "Properties" )
def cli = props.getPropertyValue("cli");
def ippresenza = props.getPropertyValue("ippresenza");
def http = new HTTPBuilder( "http://${Indirizzo_F5_FE}:${Porta_F5_FE}/AuthInterface/acctRequest?cli=${cli}&ip=${ippresenza}&sessionType=APT&msgType=START" )
http.request(GET,TEXT){ req ->
headers.'Connection' = 'Keep-Alive'
headers.'User-Agent' = 'SoapUI 4.5.1'
response.success = { resp, reader ->
assert resp.status == 200
ret = reader.getText()
}
}
props.setPropertyValue("answer", ret);
and the following groovy script to check the response:
import com.eviware.soapui.support.xml.XmlUtils
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def props = testRunner.testCase.getTestStepByName( "Properties" )
def answer = props.getPropertyValue("answer");
xmlBody = new XmlParser().parseText(answer)
errorCode = xmlBody.@errorCode
def cli = props.getPropertyValue("cli");
if ( errorCode != "5000" )
{
log.info("ACCT START UMA $cli - wrong errorCode: $errorCode")
testRunner.fail( "errorCode" )
}
Now I try to send a post http request, but I'm not able to build the correct request to send the following post boby:
input=<?xml version="1.0" encoding="UTF-8"?><UNCMARRequest xmlns="UdbCxInterface"xmlns:xsi="http://www.w3.org/2001 /XMLSchema-instance"xsi:schemaLocation="UdbCxInterface C:\UNCMARRequest.xsd"><username>${id}</username><resourceIp>${ippresenza}</resourceIp><msgType>REGISTER</msgType><methodType>UserProfile</methodType><version>${versioneCx}</version><uncId>TIMUNC1</uncId><olo>TIM</olo></UNCMARRequest>
Someone could help me ? Thanks.