Bug in web service object: cannot pass parameters from TestCase to a SOAP web service test object

Hi,
I have created a new SOAP web service test object with a couple of variables:

<soapenv:Envelope xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:ondd=“http://ondd.be:DataSourcing:General”>

soapenv:Header/

      <CreationDateTime>${CreationDate}</CreationDateTime>

      <SenderParty>

      <InternalID>KATALON</InternalID>

      </SenderParty>

soapenv:Body

  <ondd:OfficialNumbersByCountryGetQuery>

     <country>${Country}</country>

  </ondd:OfficialNumbersByCountryGetQuery>

</soapenv:Body>

</soapenv:Envelope>

The variables are declared below:

the verification code:

RequestObject request = WSResponseManager.getInstance().getCurrentRequest()

ResponseObject response = WSResponseManager.getInstance().getCurrentResponse()

println(request.getSoapBody().toString())

println(response.getResponseText())

WS.verifyResponseStatusCode(response, 200)

assertThat(response.getStatusCode()).isEqualTo(200)

def variables = request.getVariables()

def variable0 = variables.get(‘Country’)

println(variable0.toString())

def variable1 = variables.get(‘Output1’)

println(variable1.toString())

def variable2 = variables.get(‘Output2’)

println(variable2.toString())

def variable3 = variables.get(‘CreationDate’)

println(variable3.toString())

assertThat(response.getResponseText()).contains(variable1.toString())

assertThat(response.getResponseText()).contains(variable2.toString())

So far so good, this works well when executing the Test Request And Verify.

Next step is to use the web service object in a Test Case and pass data from it as parameters:

I created a new test case:

with same variables but different values:

Script code looks like:

WS.sendRequestAndVerify(findTestObject(‘SOAP/GetOfficialNumbersByCountry’, [(‘Country’) : Country, (‘Output1’) : Output1, (‘Output2’) : Output2 , (‘CreationDate’) : CreationDate]))

When running the test case I see:

11-15-2018 03:42:12 PM - [START] - Start Test Case : Test Cases/GetOfficialNumbers Test Case

11-15-2018 03:42:12 PM - [INFO] - Evaluating variables for test case

11-15-2018 03:42:12 PM - [INFO] - Variable ‘Country’ is set to FR as default

11-15-2018 03:42:12 PM - [INFO] - Variable ‘Output1’ is set to FR0 as default

11-15-2018 03:42:12 PM - [INFO] - Variable ‘Output2’ is set to FR1 as default

11-15-2018 03:42:12 PM - [INFO] - Variable ‘CreationDate’ is set to 2018-11-15T12:12:12Z as default

11-15-2018 03:42:12 PM - [START] - Start action : sendRequestAndVerify

11-15-2018 03:42:12 PM - [INFO] - Finding Test Object with id ‘Object Repository/SOAP/GetOfficialNumbersByCountry’

11-15-2018 03:42:12 PM - [INFO] - Checking request object

11-15-2018 03:42:13 PM - [INFO] - Start verifying response

11-15-2018 03:42:13 PM - [START] - Start Test Case : Verification

11-15-2018 03:42:13 PM - [START] - Start action : Statement - request = com.kms.katalon.core.webservice.verification.WSResponseManager.getInstance().getCurrentRequest()

11-15-2018 03:42:13 PM - [END] - End action : Statement - request = com.kms.katalon.core.webservice.verification.WSResponseManager.getInstance().getCurrentRequest()

11-15-2018 03:42:13 PM - [START] - Start action : Statement - response = com.kms.katalon.core.webservice.verification.WSResponseManager.getInstance().getCurrentResponse()

11-15-2018 03:42:13 PM - [END] - End action : Statement - response = com.kms.katalon.core.webservice.verification.WSResponseManager.getInstance().getCurrentResponse()

11-15-2018 03:42:13 PM - [START] - Start action : Statement - println(request.getSoapBody().toString())

<soapenv:Envelope xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:ondd=“http://ondd.be:DataSourcing:General”>

soapenv:Header/

     <CreationDateTime>2018-11-15T12:00:00Z</CreationDateTime>

     <SenderParty>

     <InternalID>KATALON</InternalID>

     </SenderParty>

soapenv:Body

  <ondd:OfficialNumbersByCountryGetQuery>

     <country>BE</country>

  </ondd:OfficialNumbersByCountryGetQuery>

</soapenv:Body>

</soapenv:Envelope>

11-15-2018 03:42:13 PM - [END] - End action : Statement - println(request.getSoapBody().toString())

11-15-2018 03:42:13 PM - [START] - Start action : Statement - println(response.getResponseText())

<SOAP-ENV:Envelope xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/”>SOAP-ENV:Header/SOAP-ENV:Body<ns3:OfficialNumbersByCountryGetResponse xmlns:ns3=“http://ondd.be:DataSourcing:General”/></SOAP-ENV:Body></SOAP-ENV:Envelope>

11-15-2018 03:42:13 PM - [END] - End action : Statement - println(response.getResponseText())

11-15-2018 03:42:13 PM - [START] - Start action : verifyResponseStatusCode

11-15-2018 03:42:13 PM - [INFO] - Checking response object

11-15-2018 03:42:13 PM - [PASSED] - Verify response status code successfully

11-15-2018 03:42:13 PM - [END] - End action : verifyResponseStatusCode

11-15-2018 03:42:13 PM - [START] - Start action : Statement - org.assertj.core.api.Assertions.assertThat(response.getStatusCode()).isEqualTo(200)

11-15-2018 03:42:13 PM - [END] - End action : Statement - org.assertj.core.api.Assertions.assertThat(response.getStatusCode()).isEqualTo(200)

11-15-2018 03:42:13 PM - [START] - Start action : Statement - variables = request.getVariables()

11-15-2018 03:42:13 PM - [END] - End action : Statement - variables = request.getVariables()

11-15-2018 03:42:13 PM - [START] - Start action : Statement - variable0 = variables.get(“Country”)

11-15-2018 03:42:13 PM - [END] - End action : Statement - variable0 = variables.get(“Country”)

11-15-2018 03:42:13 PM - [START] - Start action : Statement - println(variable0.toString())

BE

11-15-2018 03:42:13 PM - [END] - End action : Statement - println(variable0.toString())

11-15-2018 03:42:13 PM - [START] - Start action : Statement - variable1 = variables.get(“Output1”)

11-15-2018 03:42:13 PM - [END] - End action : Statement - variable1 = variables.get(“Output1”)

11-15-2018 03:42:13 PM - [START] - Start action : Statement - println(variable1.toString())

BE0

11-15-2018 03:42:13 PM - [END] - End action : Statement - println(variable1.toString())

11-15-2018 03:42:13 PM - [START] - Start action : Statement - variable2 = variables.get(“Output2”)

11-15-2018 03:42:13 PM - [END] - End action : Statement - variable2 = variables.get(“Output2”)

11-15-2018 03:42:13 PM - [START] - Start action : Statement - println(variable2.toString())

BE1

11-15-2018 03:42:13 PM - [END] - End action : Statement - println(variable2.toString())

11-15-2018 03:42:13 PM - [START] - Start action : Statement - variable3 = variables.get(“CreationDate”)

11-15-2018 03:42:13 PM - [END] - End action : Statement - variable3 = variables.get(“CreationDate”)

11-15-2018 03:42:13 PM - [START] - Start action : Statement - println(variable3.toString())

2018-11-15T12:00:00Z

11-15-2018 03:42:13 PM - [END] - End action : Statement - println(variable3.toString())

11-15-2018 03:42:13 PM - [START] - Start action : Statement - org.assertj.core.api.Assertions.assertThat(response.getResponseText()).contains(variable1.toString())

11-15-2018 03:42:13 PM - [END] - End action : Statement - org.assertj.core.api.Assertions.assertThat(response.getResponseText()).contains(variable1.toString())

11-15-2018 03:42:13 PM - [FAILED] - Verification FAILED because (of) (Stack trace: java.lang.AssertionError:

Expecting:

<“<SOAP-ENV:Envelope xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/”>SOAP-ENV:Header/SOAP-ENV:Body<ns3:OfficialNumbersByCountryGetResponse xmlns:ns3=“http://ondd.be:DataSourcing:General”/></SOAP-ENV:Body></SOAP-ENV:Envelope>”>

to contain:

<“BE0”>

at sun.

From this I conclude that variable values passed from Test Case are not used in the web service object! From the logs on my server it seems that the first variable (Country) does get trough (even if from the logging it seems it does not) while all other variables are still using the default set on the web object.

Am I doing something wrong? It looks to me like a major bug in Katalon Studio!

Thanks for your help!

Screenshot 2018-11-15 at 15.33.06.png

Screenshot 2018-11-15 at 15.38.28.png

Screenshot 2018-11-15 at 15.39.28.png

Mhm … I am just guessing here, since I never used the coding form yo do, but here a possible explanation …

You are using this into the testcase:

WS.sendRequestAndVerify(findTestObject('SOAP/GetOfficialNumbersByCountry', [('Country') : Country, ('Output1') : Output1, ('Output2') : Output2 , ('CreationDate') : CreationDate]))

I may happen that, with this code, the request object is sent ‘as it is’, initiated with the values defined in the repository (this is why also the verification snippets are executed)

Try this instead (I use like this with REST, not with SOAP … but should be same story)

 request = findTestObject('SOAP/GetOfficialNumbersByCountry', [('Country') : Country, ('Output1') : Output1, ('Output2') : Output2 , ('CreationDate') : CreationDate])

WS.sendRequestAndVerify(request)

With this form, a new object should be instantiated from the blueprint defined in Object Repository, built with the variable passed from the testcase.

If this is working, then the rest of the chain (binding data from TestData to TestSuite) should work just fine.

(you may have to put also all verification’s into the test script, may not be executed anymore from the snippets defined)

If not, it may be a valid bug with the SOAP request implementation … or something else.

2 Likes

Hi Ibus,

Thanks for your answer, I tried it but I see no difference. Must be a bug then. anyway the way the code was initially formulated is what Katalon Studio generates automatically so that should work too. Thanks for the follow-up, we are currently blocked by this, I proposed to use Katalon for API (and later UI testing) but if this does not get soveld I’m afraid we need to redo the work with another tool.

Do you need any additional info to pinpoint the problem?

Kind regards,

Adrian

anyway the way the code was initially formulated is what Katalon Studio generates automatically

that is not relevant, the generated templates are just a ‘good guess’

unfortunately i cannot reproduce (yet) the issue, since, as i already said, i am mostly using REST request into my tests.

I will try to find a ‘free to test’ SOAP api to reproduce it, until then, I believe it may be a valid bug.

Hi,
I created my own SOAP web service who logs input and output and I think I found the problem.

The good news is that the parameters are passed correctly, however it does certainly not seem so if you look at the printout from Katalon (the request object still prints out TestObject data instead of TestCase data). Also verification code has to move from TestObject to TestCase to be able to use correct values for the variables:

import static org.assertj.core.api.Assertions.*

import com.kms.katalon.core.testobject.ResponseObject

import com.kms.katalon.core.webservice.verification.WSResponseManager

TestObject testObject = findTestObject(‘SOAP/MirrorWebMethod’, [(‘variable1’) : variable1, (‘variable2’) : variable2, (‘variable3’) : variable3, (‘Output1’) : Output1, (‘Output2’) : Output2])

WS.sendRequestAndVerify(testObject)

ResponseObject response = WSResponseManager.getInstance().getCurrentResponse()

print(response.getResponseText())

WS.verifyResponseStatusCode(response, 200)

assertThat(response.getStatusCode()).isEqualTo(200)

assertThat(response.getResponseText()).contains(Output1)

assertThat(response.getResponseText()).contains(Output2)

this part will still give wrong output but it is not essential:

RequestObject request = WSResponseManager.getInstance().getCurrentRequest()

print(request.getSoapBody().toString())

Thanks for your help, it actually pointed me in the right direction (the advice to move code from TestObject validation to Test case).

However I suggest Katalon team looks at this and maybe puts out a tutorial on how to pass parameters to SOAP and verify output to avoid others wasting valuable time with this issue. The wonderful think about Katalon is that you do not need to be a groovy expert to be able to use it (but this case proves the contrary)…

Kind regards,

Adrian

Nice to hear.

You can simplify a bit the code, e.g instead of:

WS.sendRequestAndVerify(testObject)
ResponseObject response = WSResponseManager.getInstance().getCurrentResponse()

you can just do:

response = WS.sendRequest(testObject)

and you have anything needed in the response object:

WS.verifyResponseStatusCode(response, 200)
assert blah blah blah
1 Like

I attempt to encapsulate verification codes in a REST web service object by utilizing sendRequestAndVerify method and I encounter the same issue of not able to pass parameters from TestCase to a REST web service object.

As our test cases in test suites are driven by test data file, it’s important for binding test data values being passed down to REST web service object.

I appreciate the idea of sendRequestAndVerify as it allows encapsulation of verification codes in one place, but it’s not very useful until this issue is resolved. I think Katalon team should have a look at this bug to have it addressed.

I confirm that using sendRequest and put verification codes in test case level is a working workaround. Thank you for sharing the workaround.

Hi all,

is there any news on this issue, meanwhile?

As far as I could drill it down, it’s not the problem that parameters are not passed (they are, in fact) but that they are not reflected in the request retrieved by the getCurrentRequest() method in the web service object.

For logging reasons, I should be able to access this information (i.e. the really current values) in the service object (once) not on every call in a testcase (where by the way it is only the values passed to the service object, not the values received and treated!)

Regards,
Thomas