I posted this tutorial as an answer to a question, but there's been enough discussion that I'm separating it into a separate thread.
Here are the basic instructions. Let me know if you have any questions.
Step 1 – In your favourite java IDE, add the jar files from the bin directory in your DevTest (aka Service Virtualization or LISA) installation directory:
Step 2 – Create a new Java class that extends DataProtocol. It is recommended you extend ParameterListDataProtocol to make things easier, but not required.
Step 3 – Override and implement “public void updateRequest(TestExec testExec, Request request)”
This method is called to parse the request into readable data.
Make sure to call request.setOperation(operationName) to set the operation name for the request
Pull out the fields that are important for determining which fields you want to match on using request.getArguments().addParameter(new Parameter(“Name of Field”, “Value of field”));
Step 4 – Override and implement “public void updateResponse(TestExec testExec, Response response)”
This method is called to parse the response. It’s used only for displaying the response in a user friendly format. In playback mode this isn’t called
Call response.setBody(xmlResults) to set the response after converting it into a user friendly format (XML is recommended)
Step 5 – Override and implement “public void updateResponse(TestExec testExec, TransientResponse transientResponse)”
This method is called in playback mode to generate the response (ie. converts the user friendly version of the response into the format required by the system)
Call transientResponse.setBody(response) to set the response after converting it to the correct format
Step 6 – Create a file in your project. The name can be anything, but the extension must be “.lisaextensions”. In the file you’ll specify the details of your new Data Protocol Handler:
- com.example.MyNewDPH =Data:req:resp,A Good Name For My Handler,A Description of What It Does
Step 7 – Export the classes and lisaextensions file as a jar and place them in the hotdeploy directory in the DevTest (aka Service Virtualization or LISA) installation directory.
Note if you make an update, close the workstation and reopen it to pick up the changes.
Attached is a sample implementation of a DPH and the associated lisaextensions file. Let me know if you have any questions.