Forum Discussion

punter's avatar
punter
Contributor
7 years ago

Test by passing data to different attribtes of same xml through excel

i am having a scenario where i  have same response for below two type of request.

 

So i need to pass the two types of request data through excel using groovy ,pls help asap

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sear="http://schemas.microsoft.com/LiveSearch/2008/03/Search">
<soapenv:Header/>
<soapenv:Body>
<sear:SearchRequest>
<sear:parameters>
<sear:Country>India</sear:Country>
<sear:City>BH</sear:City>
<sear:Sources>
<!--Zero or more repetitions:-->
<sear:Key></sear:Key>
</sear:Sources>
<!--Optional:-->
</sear:parameters>
</sear:SearchRequest>
</soapenv:Body>
</soapenv:Envelope>

 

 

request 2 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sear="http://schemas.microsoft.com/LiveSearch/2008/03/Search">
<soapenv:Header/>
<soapenv:Body>
<sear:SearchRequest>
<sear:parameters>
<sear:Country></sear:Country>
<sear:City></sear:City>
<sear:Sources>
<!--Zero or more repetitions:-->
<sear:Key>23</sear:Key>
</sear:Sources>
<!--Optional:-->
</sear:parameters>
</sear:SearchRequest>
</soapenv:Body>
</soapenv:Envelope>

 

Respnse

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<sear:Respnose>
<sear:Country>India</sear:Country>
<sear:City>BH</sear:City>
</sear:Respnose>
</soapenv:Body>
</soapenv:Envelope>

 

3 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Not sure what is the exact issue? Can you please elaborate if you are still in need of solution?
    • punter's avatar
      punter
      Contributor

      Hi Nmrao ,

       

      I have a an xml below

       

      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://webservices.amazon.com/AWSECommerceService/2011-08-01">
         <soapenv:Header/>
         <soapenv:Body>
            <ns:CartAdd>
               <!--Optional:-->
               <ns:MarketplaceDomain>?</ns:MarketplaceDomain>
               <Domains>
                        <Domain ExternalCode="Bounrt" Value="3"/>
                        <Domain ExternalCode="EVrtrt" Value="SE"/>
                        <Domain ExternalCode="EVArt" Value="SpecialEvents"/>
                        <Domain ExternalCode="SubmissionReceivedDt" Value="2017-03-27T00:00:00-05:00"/>
                     </Domains>
            
            </ns:CartAdd>
         </soapenv:Body>
      </soapenv:Envelope>

       

      Want to send random value in attribute ExternalCode

       

      Please help on this

      • nmrao's avatar
        nmrao
        Champion Level 3

        punter,

         

        Try one of the two methods as given below:

         

        Random String of 10 letters

        You may use below code snippet to generate 10 lettered string

         

        new Random().with (1..10).collect (('a'..'z').join().toString()nextInt(25) ] }.join() }

         

        If you want it to apply your case, this can be done inline of the xml

         

        <Domain ExternalCode="${= new Random().with { (1..10).collect { (('a'..'z').join().toString()) [ nextInt(25) ] }.join() }}" Value="3"/>

         

        Or you may also use uuid

         

         <Domain ExternalCode="${= UUID.randomUUID()}" Value="SE"/>