Service Virtualization

Expand all | Collapse all

using HTTP/S Live invocation to get remote content works, but the content is not sent to the original requestor..help!  -- working now

  • 1.  using HTTP/S Live invocation to get remote content works, but the content is not sent to the original requestor..help!  -- working now

    Posted Mar 09, 2016 10:38 AM

    I have this VSM (using DT 8.5.0) that has a few script steps, then executes an HTTP/S live invocation step  to pass the request on to the  original server.

     

    I get the correct response from the server, and now let it fall thru to do the normal respond processing

     

    script step 1

    script step 2

    http/s live invocation

    prepare response

    respond

    the response at postman looks good, except no data

    return code is 200 OK

    the  headers come back properly

    • Access-Control-Allow-Headers →origin, content-type, accept
    • Access-Control-Allow-Methods →GET, POST, DELETE, PUT, PATCH, OPTIONS, HEAD
    • Access-Control-Allow-Origin →*
    • Cache-Control →no-store
    • Connection →keep-alive
    • Content-Encoding →gzip
    • Content-Length →10
    • Content-Type →application/json
    • Date →Wed, 09 Mar 2016 12:47:11 GMT
    • Pragma →no-cache
    • Server →nginx/1.8.0
    • X-xx-TransactionID →update1002
    • X-Powered-By →DevTest/8.5.0 (8.5.0.289); CA, Inc.

     

     

    I removed the leading < to make this show

    the response data from the Respond step looks like this

    java.util.Arrays_-ArrayList>

      <a class="TransientResponse-array">

        <TransientResponse xmlns="http://www.ca.com/com/itko/lisa/vse/stateful/model/v1.0">

          <id>0</id>

          <binary>false</binary>

          <charset>UTF-8</charset>

          <metaData>

            <p key="HTTP-Response-Code">200</p>

            <p key="HTTP-Response-Code-Text">OK</p>

            <p key="Access-Control-Allow-Headers">origin, content-type, accept</p>

            <p key="Access-Control-Allow-Methods">GET, POST, DELETE, PUT, PATCH, OPTIONS, HEAD</p>

            <p key="Access-Control-Allow-Origin">*</p>

            <p key="Cache-Control">no-store</p>

            <p key="WasGzip">gzip</p>

            <p key="Content-Encoding">gzip</p>

            <p key="Content-Type">application/json</p>

            <p key="Date">Wed, 09 Mar 2016 12:47:11 GMT</p>

            <p key="Pragma">no-cache</p>

            <p key="Server">nginx/1.8.0</p>

            <p key="X-XX-TransactionID">update1002</p>

            <p key="Content-Length">169</p>

            <p key="Connection">keep-alive</p>

          </metaData>

          <body>

            <bodyAsString>{&quot;firstName&quot;:&quot;Tommy&quot;,&quot;lastName&quot;:&quot;Dreamer&quot;,&quot;displayName&quot;:&quot;John132&quot;,&quot;email&quot;:&quot;Test198@mailinator.com&quot;,&quot;title&quot;:&quot;AD&quot;,&quot;locale&quot;:&quot;en_US&quot;,&quot;username&quot;:&quot;Test198@mailinator.com&quot;,&quot;tivoliUuid&quot;:&quot;7798e011-2627-4601-8176-c6cb63de8bfc&quot;}</bodyAsString>

          </body>

          <unknown>false</unknown>

          <thinkTimeSpec>0</thinkTimeSpec>

        </TransientResponse>

      </a>

    /java.util.Arrays_-ArrayList>

     

    the only thing I could think of is the  Content-Encoding header

    so I added a filter on the live inv step, to remove it, but my filter never executes..

    process responses, use lisa.vse.response, this script is on both process tabs.. record and playback

     

    %groovy%

    import com.itko.util.ParameterList;

    _logger.info("IN FILTER r")

    // Metadata is a ParameterList

    ParameterList metadata = lisa_vse_response.getMetaData();

    String ce=metadata.getParameter("Content-Encoding")

     

     

    _logger.info("filter has parm="+ce)

    if(ce!=null && ce.equalsIgnoreCase("gzip"))

    {

       _logger.info("removing")

        metadata.removeParameter("Content-Encoding")

        lisa_vse_response.setMetaData(metadata);

    }

    no log entry is recorded



  • 2.  Re: using HTTP/S Live invocation to get remote content works, but the content is not sent to the original requestor..help!
    Best Answer

    Posted Mar 10, 2016 04:58 PM

    finally got it

     

    Net, 2 problems

     

    1. 1. There were two headers, WASGzip and Content-Encoding that said the content was to be zipped
    2. 2. The content FROM the source server was html encoded, where ‘”’ was ‘&quot;’

     

    So, to fix I had to

    1. 1.      Uncheck Format as XML from my Live Invocation steps
    2. 2.      Change the next step from the live invocations to be Respond, not Prepare Response
    3. 3.      Add a scriptable filter to the Respond step to
      1. a.      Remove the two offending metadata tags
      2. b.      Modify the body string to replace ‘&quot;’ with double quote ‘”’

     

    Now it works as expected..



  • 3.  Re: using HTTP/S Live invocation to get remote content works, but the content is not sent to the original requestor..help!  -- working now

    Posted Mar 10, 2016 06:21 PM

    can someone select the prior post as the answer? I cannot

    or convert it to a question



  • 4.  Re: using HTTP/S Live invocation to get remote content works, but the content is not sent to the original requestor..help!  -- working now

    Posted May 11, 2016 08:59 AM

    Hey sdetweil2,

     

    Converted to a question and marked your comment as the answer

     

    Thanks,

    Melanie