Service Virtualization

 View Only
Expand all | Collapse all

Get content through a request url

  • 1.  Get content through a request url

    Posted Jul 02, 2020 11:58 AM
    Hello everyone,

    I have a Rest API that sends the request content via the URL, in the form:

    http: // address: port / input = content

    The content is an xml. My question is whether there is a function in devtest capable of obtaining data from the content passed in the url. I know that there is a way to get the content passed in the body of the request but I don't know how to get the content passed through the url.

    Thank you all.

    ------------------------------
    Matheus Souza
    Capgemini-BR
    ------------------------------


  • 2.  RE: Get content through a request url

    Posted Jul 02, 2020 12:08 PM
    Hi Matheus,

    Is it like http://localhost:8099/?Content=12334e or http://localhost:8099/Content=12334e

    Also, are you trying to create a test case or a virtual service out of this?

    Thanks

    ------------------------------
    Regards,
    Vaibhav Jain
    Capgemini
    ------------------------------



  • 3.  RE: Get content through a request url

    Posted Jul 02, 2020 01:08 PM
    Hi Vaibhav,

    Is it in the form http: // localhost: 8099 /? Content = 12334e.
    I am trying to create a virtual service.

    Thanks


  • 4.  RE: Get content through a request url

    Posted Jul 02, 2020 01:34 PM
    Hi Matheus,

    Assume your url is as below:
    http://localhost:8098/task_id?task_number=1234556

     [the part after ? becomes querystring and considered as a parameter] In this case your virtual service will be like 


    Thanks

    ------------------------------
    Regards,
    Vaibhav Jain
    Capgemini
    ------------------------------



  • 5.  RE: Get content through a request url

    Posted Jul 02, 2020 01:50 PM
    Ok, I get it.
    But is there any way to get this parameter via script? I know lisa_vse_http_current_transaction_body.toString (); get the body of the request. Is there anything similar to retrieve the url?

    Thank you


  • 6.  RE: Get content through a request url
    Best Answer

    Posted Jul 02, 2020 02:24 PM
    Hello Matheus,

    Try using in beanshell lisa_vse_request.getArguments() to get the parameters and then extract them to variables..


    ParameterList args = lisa_vse_request.getArguments();

    String Content = args.getParameterValue("Content");

    Regards




  • 7.  RE: Get content through a request url

    Posted Jul 02, 2020 02:31 PM
    Edited by Vaibhav Jain Jul 02, 2020 02:40 PM
    You can use either script to access the same or use RDC or RDM. 

    With RDC: it will be as below:


    Post configuration, the value of attribute could be accessed by {{request_task_idtest)

    Thanks

    ------------------------------
    Regards,
    Vaibhav Jain
    Capgemini
    ------------------------------



  • 8.  RE: Get content through a request url

    Broadcom Employee
    Posted Jul 02, 2020 01:50 PM
    Hi Matheus,

    With Request Data Copier DPH, you can create properties for the Arguments/MetaData/Attributes/Request Body. See the documentation at https://techdocs.broadcom.com/content/broadcom/techdocs/us/en/ca-enterprise-software/devops/devtest-solutions/10-5/using/using-service-virtualization/using-devtest-workstation-with-service-virtualization/creating-service-images/using-data-protocols/request-data-copier-data-protocol.html.

    Regards,
    Prema



  • 9.  RE: Get content through a request url

    Posted Jul 06, 2020 07:54 AM
    Hello everyone,
    sorry for the delay. I solved the problem using RogerGut's solution with lisa_vse_request.getArguments ();
    Thank you all.


  • 10.  RE: Get content through a request url

    Posted Jul 06, 2020 07:58 AM
    Thanks for the update.

    ------------------------------
    Regards,
    Vaibhav Jain
    Capgemini
    ------------------------------