Service Virtualization

 View Only
  • 1.  Response xml - get a tag value and replace it

    Posted Sep 28, 2018 03:07 AM

    I have a requirement in which for a complete response a particular tag value needs to be replaced by another value. That tag may occur 3 or 4 times in a response. Could you please help me with this requirement.

     

    Example: In below XML, needs to modify Addr1 tag value 

    <LocationInfo>

    <a:Addr>

        <a:Addr1> STREET ADDRESS</a:Addr1>

       <a:City>CITYNAME</a:City>

       <a:PostalCode>06001</a:PostalCode>

    </a:Addr>

    <a:DetailedAddr>

       <a:Addr1> STREET ADDRESS1</a:Addr1>

       <a:City>CITYNAME1</a:City>

       <a:PostalCode>06002</a:PostalCode>

    </a:DetailedAddr>

    </LocationInfo>



  • 2.  Re: Response xml - get a tag value and replace it

    Broadcom Employee
    Posted Sep 28, 2018 08:40 AM

    Hi,

     

    On order to suggest a direction for a solution you need to clarify some of the requirements

     

     

       

    •   As a concept, a “tag value” is not described by XML standards (AFAIK), so that leaves the question: in the below example what needs to be replaced, is it the name of the element itself, i.e. is it “Addr1” what is between ‘<’ and ‘>’? Or is it the text value of the argument <Addr1>, i.e. is it “STREET ADDRESS” and “STREET ADDRESS1”?

     

    Maybe easiest, if for the below example you also show how the original response looks like and how the final response XML needs to look like?

     

     

       

    •   For one of the above that needs to change, where does the new value come from? Does it come from somewhere inside the incoming request?

     

     

       

    •   From what value inside the request do you know if you need to respond with 2 changed tags (as below), or when it needs to be 3, or when it needs to be 4?

    Is it only 2, 3 or 4? Or can it even be more dynamic?

     

    Cheers,

    Danny



  • 3.  Re: Response xml - get a tag value and replace it

    Broadcom Employee
    Posted Sep 28, 2018 09:12 AM

    Hi Danny

              Is scriptable Data protocol on the response side help meet this requirement ?

    Scriptable Data Protocol - DevTest Solutions - 10.3 - CA Technologies Documentation 

     

    -Sankar



  • 4.  Re: Response xml - get a tag value and replace it

    Broadcom Employee
    Posted Sep 28, 2018 09:37 AM

    Possibly, yes, or some other custom steps added to the vsm workflow. But I don’t fully understand the exact requirements, hence some further questions asked.

     

    Cheers,

    Danny



  • 5.  Re: Response xml - get a tag value and replace it

    Posted Oct 01, 2018 01:10 AM

    Hi Danny,

     

    Please find the answers below:

     

    1. In the above example, tag value needs to be replaced that is  “STREET ADDRESS” and “STREET ADDRESS1”. And the final response will have only these tag value replaced.

     

    2. And the new value which is to be replaced is passed from input excel sheet.

     

    3. It Is Dynamic. If the tag name contains "*:Addr1" then its corresponding value needs to be changed. Namespace may differ.

     

    Thanks for your response.

     

    Regards,

    Geethalakshmi V



  • 6.  Re: Response xml - get a tag value and replace it

    Broadcom Employee
    Posted Oct 01, 2018 02:01 AM

    Hi,

     

     

    I was assuming this was a replacement at runtime when the virtualvservice was being used during testing. But now I am not sure anymore.

     

    Can you confirm, is this at runtime, or at design time of the virtual service?

     

    Thanks,

    Danny

     

    Outlook voor Android<https://aka.ms/ghei36> downloaden



  • 7.  Re: Response xml - get a tag value and replace it

    Posted Oct 01, 2018 07:01 AM

    Hi Danny..

    This is during Runtime 



  • 8.  Re: Response xml - get a tag value and replace it

    Broadcom Employee
    Posted Oct 01, 2018 08:19 AM

    Hi,

     

    If there is a (static) excel with values to be used for “STREET ADDRESS” , “STREET ADDRESS1”, “STREET ADDRESSx”, …  which is to be used at runtime, then it seems that a data-driven virtual service could help you implement this. Have a look in the portal where you can create this kind of virtual service.

     

    Cheers,

    Danny