What are message proxies and how are they used?
When getting started with Virtualize, it is often a good idea to
get ahold of some traffic going from your client to your service
so that you have a better understanding of the transport between
the two. The best way to do this when using Virtualize is by using
a message proxy.
The first thing you will want to do when creating your proxy is
look over at the Virtualize server view on the right hand side of
your Virtualize instance. Here, if you expand the server tab, you
should see your "local machine" server. If it is not already,
expand this as well. At that point, the "Message Proxies" folder
will be visible.
Right click this folder and select Add Message Proxy. This will
not immediately create the proxy itself, so we need to take a
couple extra steps to create and configure it. From here, double
click on the Proxy that was created under the Message Proxies
folder. From here, click on the Connections tab. On this screen,
you can view any active proxies that were created as part of this
proxy "container." To add a proxy, click on the Add button at the
bottom of the table.
Next we will want to add our connection settings. These settings
will be different for every service, so make sure that you are
double-checking these settings as they are being input. The first
connection you will make is from the incoming client. This setting
should be something that is easily identifiable as being the proxy,
so it is considered best practice to make this incoming path the
same path as the connection to the service that you are trying to
emulate, but add in "/proxy/" to the beginning of it.
- Once that has been done, we need to enter in the connection settings
for the service that we are trying to emulate. If you are following
the best practice as shown above, you need only enter in the service
host and port, then paste the rest of the path after /proxy/ as shown
above into the service forward path section.
After this is done, click OK and >>REMEMBER TO SAVE YOUR PROGRESS<<.
Next, you need to point your client application at the proxy you just
created. This is often done in the source code of the client application.
If you were following the best practices as stated above, you need only
change the host and port of the target application and then add in
/proxy/ to the path.
Now that you have configured your client application, the only thing
we have left is to enable our proxy in Virtualize by right-clicking
it in the Virtualize server view in Virtualize and clicking enable.
Once it has finished deploying, you should be able to use your client
application as normal, but instead of going directly to the live
service, it will be getting diverted through the proxy to the live
service. To create the traffic, all you need to do is end your
recording by right clicking the proxy once again and selecting "Stop
Recording." The next step when creating traffic is to right click the
enabled proxy and select start recording. All traffic that flows
through this proxy will then get recorded into a traffic file that
you can locate by moving over to the navigator view in Virtualize
and refreshing. You should see a folder called "recorded traffic"
under the Virtualize Assets Project folder.
As an alternative, you can simply monitor the traffic going between
your client and your backend by right clicking the proxy and selecting
"Start Monitoring" instead of "Start Recording". When the proxy is in
monitor mode, any messages that are sent back and forth through the
proxy are added into our Event Details Perspective. To view this
perspective, the easiest way to do this is to click on "window" at
the top of the Virtualize screen and select Perspective > Open
Perspective > Parasoft Event details.