Service Virtualization

  • 1.  capture client details

    Posted Jun 16, 2016 10:42 AM


    Is there any object in VSM/DevTest to capture client details ?

     

    Example : If I want to capture the hostname/port/url of the client which just a made call to virtual service ?



  • 2.  Re: capture client details

    Posted Jun 16, 2016 02:04 PM

    Yes, this can be done in several ways through scripting/coding.

     

    One way is to create a custom or scripted DPH. Another way is to add a Scripted step after the Listen step. In your code/script, for an HTTP VSM, you can access a property called "lisa.vse.http.current.transaction" (e.g. testExec.getStateValue("lisa.vse.http.current.transaction")). This will return a string with the information you're looking for. The string looks something like the following, and you'll just need to write some additional lines of code to parse the string for the information you want:

     

    com.itko.lisa.vse.http.HTTPTransaction[method=POST, uri=/Services/Base/Path, httpVersion=1.1, headers=Content-Type=text/xml; charset=utf-8&SOAPAction=....]

     

    You can find this property and the actual string value in the Inspection View and selecting a transaction followed by selecting the Listener step in the Request Event Details tab.



  • 3.  Re: capture client details

    Posted Jun 16, 2016 07:52 PM

    Thanks William.. Yeah I used the object lisa.vse.http.current.transaction earlier also but this gives more details about virtual service request side.. like host name here ll be host name of VS deployed .. but what I am looking is hostname of the client which sent request to VS..



  • 4.  Re: capture client details
    Best Answer

    Broadcom Employee
    Posted Jun 17, 2016 01:30 PM

    After the listen step with the following code you can get the clientIP:ClientPort. The individual values will be stored in fl_ClientIP & fl_ClientPort respectively

     

    import com.itko.lisa.vse.stateful.model.Request;

    import com.itko.lisa.vse.stateful.protocol.DataProtocol;

    import com.itko.util.Parameter;

    import com.itko.util.ParameterList;

    Request request = (Request) testExec.getStateObject("lisa.vse.request");

    String clientip = request.getMetaData().get("lisa.vse.request.client.id");

    String[] ClientUrl = clientip.split(":");

     

    testExec.setStateValue("fl_ClientIP", ClientUrl[0] );

    testExec.setStateValue("fl_ClientPort", ClientUrl[1] );

    return clientip;