Service Virtualization

  • 1.  How to convert plain text response to JMS message text and add jms parameters to this jms response

    Posted Aug 29, 2016 12:02 PM

    I have an implementation wherein to a Rest HTTP request: I have a HTTP Synchronous response (Response 1) and an aSynch response to a JMS topic (Response 2).
    So, in the vsi for this signature operation, I have Response 1 as the HTTP synch response and Response 2 as the response in plain text to be sent to JMS topic.
    Within the vsm, I am sending the HTTP Synch Response successfully.
    After sending the Synch response, within the same VSM, I am extracting response 2 and sending that message to the JMS topic.
    Now, I need to convert this plain text message to JMS message text, so that I can add some JMS parameters to this JMS text response before publishing to the JMS topic.
    I have been able to successfully add these parameters as metadata, but that does not help. These parameters needs to be added as JMS parameters and not as metadata.
    I would appreciate any tips on the best way to achieve this.

     

    Thanks

     

    Kishore



  • 2.  Re: How to convert plain text response to JMS message text and add jms parameters to this jms response

    Posted Aug 29, 2016 01:12 PM

    You don't have to build a javax.jms.Message object directly.  Just use a JMS step, either the old or new one, and you can enter message properties individually in the step itself, along with the actual message payload.  You can use {{...}} property references or {{=...}} scripts in any of those fields as well.

     

    Your larger problem is that we don't really have good support for putting multiple protocols into the same VSM.  It's doable, but there are tricks.

     

    If your HTTP respond step runs first then it will clean up all the VSE response state and there will be nothing left in the testExec to build your JMS response.  So you have to add your JMS step *before* your HTTP respond step.  Note that if you try to use the JMS VSE Respond step then it will also clean up the VSE response state and there will be nothing left for your HTTP step, so you will have to use the regular JMS test step.

     

    Once you have the step set up with the correct queue/connection information, you can just enter something like the following for the message body:

    {{=testExec.getStateObject("lise.vse.response").get(1).getBodyAsString()}}

     

    This assumes your "JMS" response is the second one in the VSI, leaving the HTTP step to send the first response when it's executed.

     

    With that out of the way, you can enter values for the message headers/properties directly in the step, either hard-coding them for every response or using an expression similar to the above one to pull then out of the VSI response meta-data or some other source.



  • 3.  Re: How to convert plain text response to JMS message text and add jms parameters to this jms response

    Posted Aug 29, 2016 02:08 PM

    Hi Kevin,

    Thanks for your response.
    I have no issues in extracting response 1 and sending that response through the Virtual HTTPS Responder.
    After the occurence of the Virtual HTTPS Responder, I also have no issues in extracting Response 2 and publishing it to the JMS Topic.
    I have to add on 2 jms properties (arg1=val1, arg2=val2) to the Response body before publishing to the JMS Topic (the new one).
    I added them through a script on to the metadata of the Response.
    A property called fullJMSResponse contains this metadata and the payload.
    In the JMS Send Receive step (the new one), the only value that Request Editor contains is the {{fullJMSResponse}} property.
    The issue is that the application does not like these 2 added properties as it comes through in metadata and/or the payload.
    It expects them as jms property.
    The question is: How do I add them as jms property? OR What is the syntax for the equivalent of adding the following metadata property (given below) as a jms property and not a metadata property:

    ParameterList metadata = aResponse.getMetaData();

    metadata.addParameter(new Parameter("arg1", val1));
    metadata.addParameter(new Parameter("arg2", val2));


    Thanks again!

    Kishore



  • 4.  Re: How to convert plain text response to JMS message text and add jms parameters to this jms response

    Posted Aug 30, 2016 11:44 AM

    I found the solution to my query in an earlier thread:

     

    How to add additional properties(other than JMS properties) in JMS request reply model response?  

     

     

    Thanks you, all!



  • 5.  Re: How to convert plain text response to JMS message text and add jms parameters to this jms response
    Best Answer

    Posted Aug 30, 2016 06:32 PM

    So using 'msg.props....' meta-data properties only works if you use the actual JMS VSE Respond step, which is possible but you will have to do some fancy manipulation of the 'lisa.vse.response' testExec properties and probably a few others in order to get it to play nicely with the HTTP respond step.

     

    If you are bypassing that and just using the regular JMS Send Receive test step then it does not understand meta-data properties or anything about the VSE request object.  You have to build the message content and any message properties manually:

     

    Enter an expression to extract the content from the VSE response object in the 'Content' section.  Make sure the 'PRO' button is enabled and click 'JMS Headers'.

     

    Click the '+' button and find the properties you want to use.

     

    You can hard code the value of a property or enter a similar expression to extract its value from the VSE Response object or some other source.