Service Virtualization

  • 1.  Capture HTTP MetaData in {{VARIABLE}} for use in JDBC Step

    Posted Nov 09, 2018 10:44 AM

    I am trying to capture some of the HTTP meta data (e.g. HTTP-URI) from an incoming request and then use that data as part of a query in the JDBC step.  I have a Scriptable DPH that gets the Request from the testExec.getStateObject("lisa.vse.request") and then sets a String variable (named "URI") using  request.getMetaData().get("HTTP-URI").  Then I am using testExec.setStateValue("URI", URI).   

     

    In the JDBC step parameters, I am trying to use that value with this reference:   {{URI}}    but the actual literal value is being passed, not the value I was attempting to pull from the request.  Can you post the Beanshell code to do this?  I am not permitted to post my code here, but I can say what I am using looks exactly like what is in the examples I have found.  It just is not getting the value from the request.

     

    Thanks,

     

    JT



  • 2.  Re: Capture HTTP MetaData in {{VARIABLE}} for use in JDBC Step
    Best Answer

    Broadcom Employee
    Posted Nov 09, 2018 11:00 AM

    Hi Jeff,

     

    The snippets of code you post look correct. So, not sure where it the hiccup.

     

    I personally always try to use existing filters, assertions, etc...  So my suggestion would be to use a Request Data Copier DPH and copy the incoming metadata to properties. That “should” always work. If in the RDC DPH you use “request” as prefix (which I recommend) then the property to use in the JDBC step would be {{request_HTTP-URI}}

     

    If you want to pursue the scriptable DPH route then I try to assess before the JDBC step that this property URI actually exists, then at least you know if the issue is in the DPH or in the JDBC step.

     

    Easiest is to debug your VSM in the workstation ITR, and look in the properties tab. Or e.g. as a last statement of your DPH add something like System.out.println(“+++ URI = “ + testExec.getStateValue(“URI”)); and then look in the workstation log or in the VSE log for this line.

     

     

    Cheers,

    Danny



  • 3.  Re: Capture HTTP MetaData in {{VARIABLE}} for use in JDBC Step

    Posted Nov 09, 2018 11:49 AM

    Request Data Copier DPH worked like a charm.   Thank you, Sir!

     

    JT