Service Virtualization

Expand all | Collapse all

How to automatically generate an Image from Request / Response pairs?

  • 1.  How to automatically generate an Image from Request / Response pairs?

    Posted Aug 29, 2016 03:39 AM

    Hi all

     

    We are looking for a solution to automatically generate the VSE Image from Request / Response pairs. Is there a way to create the Image with a script? The ServiceImageManager command-line utility is not working for the Request / Response pairs (just recoring). We prefer a script or a tool – not the portal. We are just looking for the finished Image, nothing else. Request / Response pairs are stored in a folder – what are possible ways the get an Image by click?

     

    Thank you very much in advance



  • 2.  Re: How to automatically generate an Image from Request / Response pairs?

    Posted Aug 29, 2016 10:25 AM
      |   view attached

    I have a vsm that acts as a utility which presents a GUI so that people can put the location of the xml request/response pairs and it will build and deploy a virtual service model for you. See the project which is attached. There is a LOT of commands and java script in there but if you want to piece out just part for building image with xml request/response pairs with one command, you can.

    Attachment(s)

    zip
    instaMock_v2.zip   54 KB 1 version


  • 3.  Re: How to automatically generate an Image from Request / Response pairs?

    Posted Sep 01, 2016 06:34 AM

    Hi amfamJeff,

     

    I'm also having similar requirement. I just checked 'instaMock_v2' Devtest project and got below exception when tried to open 'instaMock_v2.vsm':

     

    Trapped Message: java.lang.ClassNotFoundException: com.itko.lisa.extensions.nodes.SMTPNode

     

    Can you also share custom JAR file which you might have created for this VSM?

     

    Thanks in advance!

     

    Sid



  • 4.  Re: How to automatically generate an Image from Request / Response pairs?

    Posted Sep 01, 2016 09:58 AM

    Hi Sid,

     

    Yes, there are some email steps in the vsm. I've attached the itkoext-smtp.jar file to this reply.  Put it in your {{lisa_home}}\lib folder and restart your workstation. If that doesn't work, let me know. I will strip out the email steps and resend the vsm.

     

    Thanks!

    ~Jeff



  • 5.  Re: How to automatically generate an Image from Request / Response pairs?

    Posted Aug 29, 2016 10:53 AM

    When you set up the CLI, did you include a parameter referencing a VRS file containing instructions, DPHs, etc.?  

    Also, in the VRS file, did you indicate that the protocol class to use is VSFromRRPairsTransport and provide a DIR path to your R/R pairs by including the <rrDir> directive in the XML?  

    I have done this in the past without issue.  However, I have not tried this in DevTest 9 and above.  

     

    Following is an excerpt from a VRS showing the Protocol and rrDir in the XML.

    <?xml version="1.0" ?>

      <RecordingSession nonLeaf="WIDE" leaf="LOOSE" asObject="true">
      <Protocol type="com.itko.lisa.vse.stateful.protocol.rrpairs.VSFromRRPairsTransportProtocol">
        <Transport allAreStateless="true" asObject="true" desensitize="false" duptxns="true">
          <exportFile/>
          <RequestSide> ... </RequestSide>
          <ResponseSide> ... </ResponseSide>
        </Transport>
        <rrDir> <<DIR_PATH_TO_RR_Pairs_HERE>> </rrDir>
        <transportProtocol>
          <Protocol type="com.itko.lisa.vse.stateful.protocol.http.HttpProtocolHandler">
            <Transport allAreStateless="true" asObject="true" desensitize="false" duptxns="false">
            </Transport>
            <listenPort>8001</listenPort>
            <targetHost>localhost</targetHost>
            <targetPort>80</targetPort>
            <useGateway>true</useGateway>
            <hostHeaderPassThrough>false</hostHeaderPassThrough>
            <ssl toClient="false" sslClientAuthType="none" toServer="false"/>
          </Protocol>
        </transportProtocol>
      </Protocol>
    </RecordingSession>



  • 6.  Re: How to automatically generate an Image from Request / Response pairs?

    Posted Aug 29, 2016 12:17 PM

    Hey, thanks a lot Jeff and Joel for your answers! Wow!

     

    The part with the VSR sounds very interesting for me. But I still need some further help. I have now a VSR File:

     

    <?xml version="1.0" ?>

      <RecordingSession nonLeaf="WIDE" leaf="LOOSE" asObject="true">
      <Protocol type="com.itko.lisa.vse.stateful.protocol.rrpairs.VSFromRRPairsTransportProtocol">
        <Transport allAreStateless="true" asObject="true" desensitize="false" duptxns="true">
          <exportFile/>
          <RequestSide> ... </RequestSide>
          <ResponseSide> ... </ResponseSide>
        </Transport>
        <rrDir>C:/temp/RR/</rrDir>

    ……… and so on…

     

    Hmm, how do I get the Image now? I tired with many examples of the ServiceImageManager.exe – without any success. I have still some problems in understanding this documentation. If I just want to generate the Image (no model) without any recording…maybe there is a workaround with combining an empty image (or fake recording)? Does someone have a magic command for doing this? I just want to automatically generate the Image from a folder with XML Req/Res. 

     

    Something like: (not working)

    (ServiceImageManager -v c:/myRecording.vrs -s c:/generatedImage.vsi

     

    Thank you very much again



  • 7.  Re: How to automatically generate an Image from Request / Response pairs?

    Posted Aug 29, 2016 01:34 PM

    Perhaps, the simplest way to do this is as follows:

    1) Start Workstation and perform a VS Recording from R/R pairs using an existing set of R/R pairs.

    2) Follow the wizard and enter all of the various configurations for your service including any protocol, Listen and host ports, DPHs, etc.

    3) On the last screen, where the Finish button is located, notice the blue folder icon (right above Finish).

    4) CLICK on the icon and save your VRS file.  This action will provide a well-formed skeleton that you can use as a template.

     

    Now that you have a VRS containing properly formatted XML, you can edit it according to your requirements.

     

    As far as the command line goes, you will then build a command that specifies the name of the service model, image, and location of the VRS file containing the instructions you want processed.  An example command line looks similar to this.

    ServiceImageManager.exe --vrs=D:\[LISA_PROJ_ROOT]\<proj_file_name>\Data\recording-session\<YourVRSFileName>.vrs -d -s D:\[LISA_PROJ_ROOT]\<proj_file_name>\VServices\Images\<yourVSIFileName>.vsi -m D:\[LISA_PROJ_ROOT]\<proj_file_name>\VServices\<yourVSMFilename>.vsm –G

     

     

    Replace the various PATH locations above as necessary to point to where files will be located...

     

    Examples of the command structure can be found in the documentation at:  ServiceImageManager Command - Manage Service Images - DevTest Solutions - 9.5 - CA Technologies Documentation  

     

    You can set this up to run from a .bat or .sh script depending on your environment.  

     

    With regard to creating the VSM, I would simply delete / remove it once the image is created.  I am not certain that you can create the VSI without having a VSM file.

     

    Hope this helps.



  • 8.  Re: How to automatically generate an Image from Request / Response pairs?
    Best Answer

    Posted Aug 29, 2016 02:32 PM

    This is the sample xml I use for my .vrs. This is what the session recording creates! So, no reason to run the session recording. Just put the location of your xml request/response pairs as the value in the rrDir tag as shown in red below. Then save the file with a .vrs extension. Then run the sample command below the xml, just put your locations in place of the ones I have. Let me know if it works.

     

    <?xml version="1.0" ?>

    <RecordingSession nonLeaf="WIDE" leaf="LOOSE" asObject="true">
        <Protocol type="com.itko.lisa.vse.stateful.protocol.rrpairs.VSFromRRPairsTransportProtocol">
            <Transport allAreStateless="false" asObject="true" desensitize="false" duptxns="false">
                <exportFile></exportFile>
                <RequestSide>
                    <Protocol type="com.itko.lisa.vse.stateful.protocol.ws.WSSOAPProtocolHandler">
                    </Protocol>
                </RequestSide>
            </Transport>
            <rrDir>{{XMLLocation}}</rrDir>
            <transportProtocol>
                <Protocol type="com.itko.lisa.vse.stateful.protocol.http.HttpProtocolHandler">
                    <Transport allAreStateless="false" asObject="true" desensitize="false" duptxns="false">
                    </Transport>
                    <listenPort>8001</listenPort>
                    <targetHost></targetHost>
                    <targetPort>80</targetPort>
                    <useGateway>false</useGateway>
                    <ssl toClient="false" toServer="false"/>
                    <keystoreFile></keystoreFile>
                    <keystorePWEnc>f5504e2d23a7888253a27e8ef52607d8</keystorePWEnc>
                </Protocol>
            </transportProtocol>
        </Protocol>
    </RecordingSession>

     

    Sample:

    C:\devtest\bin\ServiceManager.exe -d -v c:\devtest_data\VRS\sampleVRS.vrs -s C:\devtest_data\Images\sampleImage.vsi -G -E 1000



  • 9.  Re: How to automatically generate an Image from Request / Response pairs?

    Posted Aug 31, 2016 03:32 AM

    You both made my day! Thank you very much.


    It worked with the VRS-File and following command:
    ServiceImageManager.exe --vrs=y:\VSE_PILOT\default-req-res_template.vrs -d -s y:\VSE_PILOT\sampleImage.vsi -G

     

    Now we have all components to automatically build a simulation form request response pairs. The goal is that dev-teams can store the R/R in a folder and we create a script which automatically creates and deploys the sim in just some seconds. If you have any further experiences or nice templates and scripts I’m surly very interested in. Thanks again for the great support!



  • 10.  Re: How to automatically generate an Image from Request / Response pairs?

    Posted Aug 31, 2016 08:27 AM

    Max,

     

    Take a look at the original attachment I sent, the instamock project. That does exactly what you are trying to do. It is a virtual service that creates virtual services! It returns an html gui in which the developers can enter the location of xml request/response pairs and it automatically generates an entire Devtest project including vsm and vsi and deploys it to the vse. I've got a lot of stuff in there that is specific to my organization but you can probably reverse engineer quite a bit out of it for your needs.

     

    Jeff De Meyer

    Software Engineering Specialist

    Software Engineering

     

    (sent from my phone)



  • 11.  Re: How to automatically generate an Image from Request / Response pairs?

    Posted Aug 18, 2017 06:05 PM

    How to automatically generate an Image and Model from Swagger 2.0 Specification??

     

    I implemented the automatically generating image from request/response pairs but my project requires me to generate image from Swagger(JSON) file . Do anyone know how to perform this task. Please respond with a answer or any ideas.