Service Virtualization

  • 1.  Creating Virtual Service Using XML

    Posted Jan 09, 2018 03:37 PM

    What is the process of creating virtual services using XML? Also how can i give different header responses for same request?



  • 2.  Re: Creating Virtual Service Using XML
    Best Answer

    Posted Jan 09, 2018 11:07 PM

    Hi Bala, it is probably best that you review the use of Sidecar files. Let's say that I have an R/R pair with the following file names.

    someTransaction-req.txt

    someTransaction-rsp.txt

    Add a third file containing the response headers.

    someTransaction-rsp-meta.properties

     

    In the response meta-properties file add the headers you want, for example:

    HTTP-Response-Code=404
    HTTP-Response-Code-Text=Fail,Fail

    Content-Type=application/json
    transactionId=ab3CDE226fgh35IJ

    Custom-Header-Field=MyCustomHeader

     

    Refer to: https://communities.ca.com/message/241984144-re-how-to-implement-respone-and-request-pair-using-all-the-4-methods?commen…  for additional detail or check out docops at: Request/Response Pairs - DevTest Solutions - 10.1 - CA Technologies Documentation  

     

    If you needed to include multiple responses for a given request each having its own set of headers:

    - Check Allow Duplicate Specific Responses on the main panel in the RR Pair Recording wizard

    - Create a series of RR Pair Files

    someTransaction-req.txt

    someTransaction-rsp1.txt

    someTransaction-rsp1-meta.properties

    someTransaction-rsp2.txt

    someTransaction-rsp2-meta.properties

    Each response meta-properties file can have different HTTP Response headers.



  • 3.  Re: Creating Virtual Service Using XML

    Posted Jan 10, 2018 08:02 AM

    Bala, if you need duplicate responses, then Allow Dups and create multiple requests that are the same each having a different response. Assume the same request is in someTransaction1 and someTransaction2 but different responses and headers are needed.

    someTransaction1-req.txt

    someTransaction1-rsp.txt

    someTransaction1-rsp-meta.properties

    someTransaction2-req.txt

    someTransaction2-rsp.txt

    someTransaction2-rsp-meta.properties



  • 4.  Re: Creating Virtual Service Using XML

    Posted Jan 10, 2018 04:48 PM

    Hi Joel,

     

    Thanks for your reply.I tried as suggested by you.

    1) Created virtual service using req,rsp and rsp-meta.properties

    2) When i verified the virtual image I didnt see any response,instead I have see the values in meta.properties.

     

    Sample response placed below

     

    HTTP-Response-Code=500


    Server=nginx/1.9.4


    Date=Tue, {{=doDateDeltaFromCurrent("dd MMM yyyy","-435D");/*01 Nov 2016*/}} 22:46:42 GMT


    Content-Type=application/json;charset=utf-8

     

    Could you please suggest the way forward



  • 5.  Re: Creating Virtual Service Using XML

    Posted Jan 15, 2018 06:32 PM

    Hi Bala,

     

    You should create the virtual service using:

     

    someTransaction-req.txt   (Request)

    someTransaction-rsp.txt   (Response)

     

    not this one:

    rsp-meta.properties  , this is just for meta.



  • 6.  Re: Creating Virtual Service Using XML

    Posted Jan 16, 2018 09:08 AM

    The final solution included the rsp-meta.properties file in order to set the desired response codes of HTTP 500, etc. There was a subtle file name issue in the meta.properties file.

    After cleaning up filenames, the R/R Pairs were run to create a VSI which set the proper response and response codes. 

    The JSON DPH was included automatically, and we added the REST DPH manually.

    This enabled us to build a proper VSI with proper responses. 



  • 7.  Re: Creating Virtual Service Using XML

    Posted Jan 16, 2018 10:25 AM

    Hi Joel,

     

     

    Could you please let me know the details in steps to avoid the "Transfer-Encoding: chunked" issue.

     

     

    Do I need to create virtual service with out using meta-properties file?

     

     

    Thanks,

     

    Bala Subrahmanyam.T



  • 8.  Re: Creating Virtual Service Using XML

    Posted Jan 17, 2018 03:54 PM

    I believe you should open a Support Ticket on this one.

    When I send a response to Postman and SoapUI, I can see in the logs that the message is placed on the wire, but as you state, I do not see a response in the client.

    2018-01-17 20:35:18,725Z (14:35) [ProcDlgThreadCallbk@7ee9e363] INFO root - Response on the Wire HTTP/1.1 503 Fail
    Server: nginx/1.9.4
    Date: Tue, 01 Nov 2016 22:46:42 GMT
    X-Powered-By: Express
    targetverb: POST
    expires: 0
    targetstatuscode: 503
    pragma: no-cache
    access-control-allow-origin: *
    subproxyentrytime: 1478040402198
    cache-control: no-cache, no-store, must-revalidate
    Proxy-Connection: Keep-alive
    beforereqts: 1478040402199
    workerip: 152.141.3.218
    servicetime: 257
    Transfer-Encoding: chunked
    Content-Type: application/json;charset=utf-8
    Content-Length: 48466

    {
    "$type": "Ecp.Messages.Result`1[[System.Object, mscorlib]], Ecp",
    "Data": { ....

     

    2018-01-17 20:46:32,139Z (14:46)[bala [VS_bala_Run]/1] INFO - Transaction Navigator Respond from: {"id":11,"request":{"id":18,"matchTolerance":"EXACT","operation":"POST /Security271/SignInAndAuthenticate/","arguments":{"directResponse":"false","application":"MOT","hash":"ODUwNjEzMmY3MGRkM2ZlMTQzMjE0YmJlYzllNWNjZjI=","languageName":"en-US","marketId":"US","nonce":"happybaby","password":"Apple12@","platform":"android","userName":"sapientappusqa4@gmail.com","versionId":"0.0.1.I"}}}
    2018-01-17 20:46:32,140Z (14:46)[bala [VS_bala_Run]/1] INFO - Response on the Wire HTTP/1.1 500 Fail
    Server: nginx/1.9.4
    Date: Tue, 01 Nov 2016 22:46:42 GMT
    X-Powered-By: Express
    targetverb: POST
    expires: 0
    targetstatuscode: 500
    pragma: no-cache
    access-control-allow-origin: *
    subproxyentrytime: 1478040402198
    cache-control: no-cache, no-store, must-revalidate
    Proxy-Connection: Keep-alive
    beforereqts: 1478040402199
    workerip: 152.141.3.218
    servicetime: 257
    Transfer-Encoding: chunked
    Content-Type: application/json;charset=utf-8
    Content-Length: 29

    Error sending HTTP request.

     

    You might turn on DEBUG mode in the logging.properties file to see if some other malfunction is occurring. When chunked is used, I believe the last segment sent should contain a content-length of 0 bytes and no data. I cannot see if that is happening in this situation.