Service Virtualization

  • 1.  Add Authorization Header to Live Invocation

    Posted Jul 27, 2017 02:59 PM

    DevTest Version - 10.1

     

    I need to add an authorization header to a live invocation. So far, I've tried adding it to lisa.vse.request with a scriptable data protocol and added it to lisa.vse.http.current.transaction using a groovy script. In both cases, you can see that the header is added, but the live invocation step fails to pick up the authorization header. Is there another way to add in a header?

     

    For reference, the scriptable data protocol is:

    %groovy%

    import com.itko.util.ParameterList;
    import com.itko.util.Parameter;

    ParameterList metadata = lisa_vse_request.getMetaData();
    metadata.addParameter(new Parameter("Authorization", "Basic Password="));

    lisa_vse_request.setMetaData(metadata);

     

     

    The groovy script to set lisa.vse.http.current.transaction is:

    import com.itko.util.ParameterList;

    ParameterList metadata = testExec.getStateValue("lisa.vse.http.current.transaction").getRequestHeaders();
    metadata.put("Authorization", "Basic Password=");



  • 2.  Re: Add Authorization Header to Live Invocation

    Broadcom Employee
    Posted Jul 31, 2017 10:27 AM

    Did you try checking the option "Do not modify host header parameter received from client" in the Live Invocation step?



  • 3.  Re: Add Authorization Header to Live Invocation

    Posted Jul 31, 2017 03:02 PM

    Prema,

     

    Thanks, but I need to add an authorization header for the live invocation. It doesn't come in with the request.



  • 4.  Re: Add Authorization Header to Live Invocation

    Posted Jul 31, 2017 05:31 PM

    As far as I can tell, the request object used in the Live Invocation step is immutable with the exception of headers added by the DevTest framework (per Prema's post).

     

    This may require a custom approach whereby Live Invocation is replaced with a REST or WS Exec XML step. But, that means marshaling and unmarshaling data into the lisa_vse_response object so the Responder step can deal with it.



  • 5.  Re: Add Authorization Header to Live Invocation

    Posted Jul 31, 2017 08:45 PM

    I’ve been working on calling the live service with a ws exec step, then marshaling the lisa.vse.response. Everything looked ok to me, but the responder step would exit without sending a reply. I added a prepare response step, but now it’s throwing an odd XML error from the responder –

    ============================================================================

    | com.thoughtworks.xstream.io.StreamException:  : PI must not start with xml (position:unknown TransientResponse{binary=false, body=@1:41 in java.io.StringReader@1496658a)

    ============================================================================

    | Step:        Virtual HTTPS Responder

    ----------------------------------------------------------------------------

    | Message:      : PI must not start with xml (position:unknown TransientResponse{binary=false, body=@1:41 in java.io.StringReader@1496658a)

    ----------------------------------------------------------------------------

    | Trapped Exception:  : PI must not start with xml (position:unknown TransientResponse{binary=false, body=@1:41 in java.io.StringReader@1496658a)

    | Trapped Message:   com.thoughtworks.xstream.io.StreamException:  : PI must not start with xml (position:unknown TransientResponse{binary=false, body=@1:41 in java.io.StringReader@1496658a)

    ----------------------------------------------------------------------------

    STACK TRACE

    com.thoughtworks.xstream.io.StreamException:  : PI must not start with xml (position:unknown TransientResponse{binary=false, body=@1:41 in java.io.StringReader@1496658a)

                    at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:124)

                    at com.thoughtworks.xstream.io.xml.AbstractPullReader.readRealEvent(AbstractPullReader.java:148)

                    at com.thoughtworks.xstream.io.xml.AbstractPullReader.readEvent(AbstractPullReader.java:141)

                    at com.thoughtworks.xstream.io.xml.AbstractPullReader.move(AbstractPullReader.java:118)

                    at com.thoughtworks.xstream.io.xml.AbstractPullReader.moveDown(AbstractPullReader.java:103)

                    at com.thoughtworks.xstream.io.xml.XppReader.<init>(XppReader.java:63)

                    at com.thoughtworks.xstream.io.xml.AbstractXppDriver.createReader(AbstractXppDriver.java:54)

                    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1061)

                    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1052)

                    at com.itko.lisa.vse.stateful.model.Streamer.fromXML(Streamer.java:92)

                    at com.itko.lisa.vse.stateful.BaseRespondStep.getResponse(BaseRespondStep.java:312)

                    at com.itko.lisa.vse.stateful.BaseRespondStep.getResponse(BaseRespondStep.java:296)

                    at com.itko.lisa.vse.stateful.protocol.http.HttpRespondStep.respond(HttpRespondStep.java:113)

                    at com.itko.lisa.vse.stateful.BaseRespondStep.execute(BaseRespondStep.java:231)

                    at com.itko.lisa.test.TestNode.executeNode(TestNode.java:981)

                    at com.itko.lisa.test.TestCase.execute(TestCase.java:1288)

                    at com.itko.lisa.test.TestCase.execute(TestCase.java:1203)

                    at com.itko.lisa.test.TestCase.executeNextNode(TestCase.java:1188)

                    at com.itko.lisa.editor.WalkThruPanel.prepAndExecNode(WalkThruPanel.java:1085)

                    at com.itko.lisa.editor.WalkThruPanel.access$900(WalkThruPanel.java:71)

                    at com.itko.lisa.editor.WalkThruPanel$10.doCallback(WalkThruPanel.java:992)

                    at com.itko.util.swing.panels.ProcessingDialog$2.run(ProcessingDialog.java:194)

                    at java.lang.Thread.run(Thread.java:745)

    Caused by: org.xmlpull.v1.XmlPullParserException: PI must not start with xml (position:unknown TransientResponse{binary=false, body=@1:41 in java.io.StringReader@1496658a)

                    at org.kxml2.io.KXmlParser.exception(Unknown Source)

                    at org.kxml2.io.KXmlParser.error(Unknown Source)

                    at org.kxml2.io.KXmlParser.parseLegacy(Unknown Source)

                    at org.kxml2.io.KXmlParser.nextImpl(Unknown Source)

                    at org.kxml2.io.KXmlParser.next(Unknown Source)

                    at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:109)

                    ... 22 more

     

    If you have a few minutes to take a look at this, I could use some suggestions.

     

    Thanks for your help



  • 6.  Re: Add Authorization Header to Live Invocation

    Broadcom Employee
    Posted Aug 01, 2017 09:41 AM

    Hi Brian,

     

    lisa.vse.response should be in Transient form. Did you set the Web Service step response to lisa.vse.response and made it Transient?

     

    Could you open a support ticket and we can look into the issue in a WebEx?

     

    Thanks,

    Prema



  • 7.  Re: Add Authorization Header to Live Invocation

    Posted Aug 01, 2017 11:03 AM

    I checked the raw SOAP request and web service execution step. The only place I've found to store the response is the utility filter to store the step response as a property. Is there a different step or filter to try?



  • 8.  Re: Add Authorization Header to Live Invocation
    Best Answer

    Broadcom Employee
    Posted Aug 02, 2017 09:35 AM

    You can store the Web service step response to a property. Then you have to convert the response to transient form and save it to lisa.vse.response and the HTTP Rsponder should return the response properly.

     

    -Prema