Data learning is possible in Virtualize for HTTP traffic using the “Learn responses” feature in a Message Proxy. With this feature, Virtualize will learn and emulate responses recorded from a live HTTP endpoint and update a virtual asset to the most current state. The virtualized endpoint can then be used as a reliable failover when the real endpoint is not available. This minimizes the set-up efforts associated with service virtualization, reduces maintenance costs, and offers the easiest way to virtualize your service.
Generally speaking, setting up a data learning environment involves the following steps:
In this topic, we will discuss the process generally and show it in practice using the public version of ParaBank.
http://my-machine.domain.com:9088/
).http://remote-machine.domain.com:80
). Any paths and query parts sent to the proxy URL will be forwarded to the primary URL automatically. See Service Forward Path and Proxy Listen Path./my-virtual-asset
as the path, an asset named “my-virtual-asset” will be created for you.To use the public ParaBank, set the primary URL to http://parabank.parasoft.com
and the secondary endpoint to something like /parabank
.
Modify the client application to point to the where the Virtualize message proxy is running. Because you set up the HTTP Listener earlier, this is as simple as changing the host and port. For example, let's say the following is true:
remote-machine.domain.com:80
my-machine.domain.com:9088
http://remote-machine.domain.com:80/ABC/XYZ/11111/data
With the message proxy configured the way it is, all you need to do to update the client application is change the host and port of that endpoint: http://my-machine.domain.com:9088/ABC/XYZ/11111/data
When using ParaBank, the REST API service uses the endpoint http://parabank.parasoft.com:80/parabank/services/bank/customers/12212/accounts
to retrieve all the accounts registered to customer 12212. Running Virtuailze locally with the reverse message proxy we set up, we would use http://localhost:9088/parabank/services/bank/customers/12212/accounts
instead.
From your client application, make some calls to invoke the message proxy and begin data learning. Then, open Virtualize and:
/VirtualAssets/generated_by_data_learning
directory./VirtualAssets/generated_by_data_learning/my-virtual-asset_files/
data_learning
directory. You should see some traffic files that have been generated. These will be used to match incoming messages.Open a browser and go to http://localhost:9088/parabank/services/bank/customers/12212/accounts
. That's enough to create the necessary directories and start storing data, with a Request/Response Files responder in the Virtual Asset Explorer
and traffic files in the Project Explorer.
Go back to the Virtualize Server tab and right-click the message proxy you created at the beginning of this process. Enable Set HTTP Mode: Secondary to route traffic to the Virtual Asset.
With this configuration, traffic will be routed to the Virtual Asset before the live service. If the asset fails to match an incoming request against the generated traffic files, the proxy will fall back to the live service and will generate new traffic files for the new learned data. For more information on the request items considered for correlation and data retention options, refer to Request/Response Files Options.