Forum Discussion

divya_26's avatar
divya_26
Occasional Contributor
5 years ago
Solved

How to use value from jdbc response into the json payload for a web service in soap ui free version

Hi Guys,

I am working on Soap ui oopen source. I have used sql query and i am getting xml response. Now I want to use one its response as an input in request parameter for testing a web service(i am working on json format). Please suggest ways. I am new in data-driven and automation field.

 

Thanks in advance 

  • nmrao's avatar
    nmrao
    5 years ago
    Since there are 3 id's (of course, there can be many as well), the following rest step has to be repeated, correct?
    Need to write a script.
  • nmrao's avatar
    nmrao
    5 years ago

    divya_26 

     

    Here is a sample project.

    https://github.com/nmrao/sample-soapui-projects/blob/master/rest_sample/demo-loop-soapui-project.xml

     

    This project has a mock service to test the use case. But you can use it and apply to your case.

    There is one Test Suite and a Test Case. And a mock service. First you need to start it by right click. Then select the test case and run.

     

    Please note that

    1. Since it is not possible to mock jdbc step (GetJDBCResponse) , used REST test step. However, that receives same response as JDBC and response is dynamic number of both rows and ids in each call. So, in your case, this step is not required.

    2. Step 2 (Conditional Goto) will check if there are any IDs in response. It will jump to Step Continue if no IDs found in the response. You need use this step.

    3. Step 3 (DataSource) will extract data from Step1 (JDBD response) and set one ID in custom  properties at test case level. This step also saves rest of the ids. You need to use this step

    4. Step 4 (POSTRequest) . You need not to use, instead use your request.

    5. Step 5 (Loop) this step will get the ids and take next one and execute Step 4. This is continued until all ids post request is sent.

     

    Please check sample screen

     

     

     

18 Replies

    • divya_26's avatar
      divya_26
      Occasional Contributor

      nmrao sir,  here is the sample data

       

      my resonse from jdbc sql query in xml is :--

      <Results>
      <ResultSet fetchSize="0">
      <Row rowNumber="1">
      <CAT.ID>2</CAT.ID>
      </Row>
      <Row rowNumber="2">
      <CAT.ID>9</CAT.ID>
      </Row>
      <Row rowNumber="3">
      <CAT.ID>15</CAT.ID>
      </Row>
      </ResultSet>
      </Results>

       

       

      and now i want to use cat.id whose value is 15 in my new json payload having syntax :--

      {

      "id": "__"

      }

      In this id, i want to fetch 15 from the above

       

      Thanks in advance

      • nmrao's avatar
        nmrao
        Champion Level 3
        How does the script know which value from xml response (jdbc response) as you are saying 15. Is it alway fixed or does it vary? If so, how you want to handle it?