Simulate a Stateful Service
This task describes how to configure a virtual service to simulate stateful behavior.
Virtualize stateful behavior
-
Prerequisite:
Service Virtualization must have information on the message structure that the client uses. The structure of request/response messages is stored in the service description. You provide this information by doing one of the following:
- Placing the virtual service in Learning mode to record real service behavior. For example, for a REST service.
- Importing a service description document, such as when creating a SOAP service using an imported .wsdl service description document.
- Importing messages into the virtual service's data model.
-
Define session identifiers:
- In the Service Description Editor, under Session IDs Definition, click Edit.
-
In the wizard pages that open, specify values for session identifiers, and click Finish.
Client-initiated sessions: For a service in which sessions are determined based on a client request, you can select an element of the request data to use as a session identifier. For example, a user ID.
Server-initiated sessions: For a service in which sessions are determined based on a server response, you can select an element of the response data to use as a session identifier. For example, a client may send a login request, and the server returns a session ID that will identify the client session.
For user interface details, see Session ID Definition Wizard.
-
Learn data again:
Service Virtualization uses the session IDs to create different tracks based on the learned data, and uses the tracks to create different sessions during simulation.
Edit tracks
View and modify tracks using the Stateful Layout view of the Data Model Editor. For user interface details, see Stateful Layout View.
On the Data Model Editor toolbar, click Stateful Layout to display the track pane.
- Filter tracks. Select an option under Current Rule Tracks to display all tracks or tracks for current rule only.
-
Edit a track.
- Click inside a track name to edit.
-
Drag and drop items within a track to reorder.
- Delete a track. Delete the track only, or also delete the rows that include track positions of the selected track.
Reorder tracks
By default, tracks are ordered based on the track position's timestamp. For example, the first track created would be used first during simulation, the second track used next, and so on.
You can manually reorder that the tracks to redefine the sequence in which they are used during simulation.
At the bottom of the track pane, select a track you want to move and click the up/down arrows.
Create stateful behavior manually
- In the Data Model Editor, create a blank rule and add data rows.
- Create a new track. On the toolbar, click Stateful Layout to display the track pane.
- Drag and drop rows from the data rule into the Stateful Layout track pane, in the order that you want.
For user interface details, see Data Model Editor and Stateful Layout View.
See also:
- Stateful simulation
- Shopping cart session sample projects here: Welcome page.