Forum Discussion

boncwik's avatar
boncwik
New Contributor
5 years ago
Solved

Multiple SOAP requests, increasing one parameter

Hi All,

At first, apologize if this is a wrong place for this question and if that question has already been asked.

I'm a new SOAP user and have to run hundreds of SOAP requests, like that one below:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xmii="http://www.sap.com/xMII">
<soapenv:Header/>
<soapenv:Body>
<xmii:XacuteRequest>
<xmii:InputParams>
<xmii:DateStarted>2020-03-26T07:00:00.000</xmii:DateStarted>
<xmii:ExpiryTime>2021-03-26T07:00:00.000</xmii:ExpiryTime>
<xmii:Item>Material1</xmii:Item>
<xmii:Quantity>1</xmii:Quantity>
<xmii:Resource>Machine1</xmii:Resource>
<xmii:Sfc>TEST000001</xmii:Sfc>
<xmii:ShopOrder>1234567890</xmii:ShopOrder>
<xmii:UserId>QW1234</xmii:UserId>
</xmii:InputParams>
</xmii:XacuteRequest>
</soapenv:Body>
</soapenv:Envelope>

Each time I run the request I have to just increase SFC parameter with "+1". So with the second call I will send TEST000002, with the third it will be TEST000003 and so on...

I assume that I could create a test case which will do that job very quickly but I don't knwo how, I'm a dumb :)

Can someone help me creating a test case for that or maybe there is an another solution?

Thanks in advance.

  • Hello nmrao,

     

    Apologize for a late reply, I was too busy recently.

    In fact I didn't checked yet your solution but I was managed (with a help of my friend) to solve my issue.

    So, I will just describe how we solve it and maybe someone could use it in the future:

     

    1. I create a new TestSuite (called Loop) and a new TestCase (called test1) under the project:

     

    2. Inside the TestCase we define 2 steps:

     

    3. In Request1 in put a SOAP call from my first email but I replace:

    <xmii:Sfc>TEST000001</xmii:Sfc>

    With the property, which I declare in point 4:

    <xmii:Sfc>${#TestCase#sfc}</xmii:Sfc>

     

    4. Next we define couple of properties:

     

    5. In loop step we put a code:

    def prefix = context.expand( '${#TestCase#prefix}' );
    def step = context.expand( '${#TestCase#step}' );
    def limit = context.expand( '${#TestCase#limit}' ).toInteger();
    step = step.toInteger() + 1;
    
    if (step <= limit) {
    testRunner.testCase.setPropertyValue("step", step.toString());
    testRunner.testCase.setPropertyValue("sfc", prefix+step.toString());
    log.info "step: " + step;
    testRunner.gotoStepByName("Request1");
    }

     

    Now, playing with the step, sfc and limit values I was able to execute exactly what I needed  :)

3 Replies

    • boncwik's avatar
      boncwik
      New Contributor

      Hello nmrao,

       

      Apologize for a late reply, I was too busy recently.

      In fact I didn't checked yet your solution but I was managed (with a help of my friend) to solve my issue.

      So, I will just describe how we solve it and maybe someone could use it in the future:

       

      1. I create a new TestSuite (called Loop) and a new TestCase (called test1) under the project:

       

      2. Inside the TestCase we define 2 steps:

       

      3. In Request1 in put a SOAP call from my first email but I replace:

      <xmii:Sfc>TEST000001</xmii:Sfc>

      With the property, which I declare in point 4:

      <xmii:Sfc>${#TestCase#sfc}</xmii:Sfc>

       

      4. Next we define couple of properties:

       

      5. In loop step we put a code:

      def prefix = context.expand( '${#TestCase#prefix}' );
      def step = context.expand( '${#TestCase#step}' );
      def limit = context.expand( '${#TestCase#limit}' ).toInteger();
      step = step.toInteger() + 1;
      
      if (step <= limit) {
      testRunner.testCase.setPropertyValue("step", step.toString());
      testRunner.testCase.setPropertyValue("sfc", prefix+step.toString());
      log.info "step: " + step;
      testRunner.gotoStepByName("Request1");
      }

       

      Now, playing with the step, sfc and limit values I was able to execute exactly what I needed  :)

      • sonya_m's avatar
        sonya_m
        SmartBear Alumni (Retired)

        boncwik glad to hear that! thank you for sharing the solution with us!

         

        Thank you for helping nmrao, always great to have multiple options to try and solve an issue.