Mobile App Recording with SilkPerformer and the Windows Phone Emulator
When developing applications for the Microsoft Windows Phone platform, it’s common practice to utilize Web Services. Many mobile applications, for example stock tickers and weather apps, retrieve data from Web Services so that they can provide accurate and current data to the user. Usually the impact on the Web Services caused by these mobile applications is difficult to estimate. The question of how scalable or redundant a Web Service must be is one of the biggest challenges faced by mobile application developers.
This article demonstrates how Silk Performer supports the process of developing and testing these types of applications by recording and customizing data exchanged between the mobile application running inside the Windows Phone Emulator and a Web Service.
Using this approach, developers can load and performance test their Web Services in advance to gain a better understanding of scalability and redundancy requirements.
A simple Windows Phone Silverlight project will serve as our example for recording and customizing the traffic generated by the Windows Phone emulator.
Make sure you have Microsoft Visual Studio and the Windows Phone Developer Tools installed before getting started with the example.
These tools can be downloaded from http://msdn.microsoft.com. This site is a great resource for finding answers to questions you may have about Windows Phone development.
The sample application used throughout this article is a basic Windows Phone Silverlight application that retrieves data from a WCF Web Service hosted on a Borland Web server.
After building and launching the sample project in Microsoft Visual Studio, the Windows Phone emulator launches and runs the sample application. Its user interface is simplistic, consisting of only a button and a text field that displays the data retrieved by the Web Service when the button is pushed.
To record network traffic generated by the Windows Phone emulator, a new application profile must be created in Silk Performer:
- Launch Silk Performer
- Select Settings | System… to open the System Settings dialog.
- On the Recorder | Application Profiles tab, click the Add… button.
- Create a new application profile called WP7 Emulator and specify the path to the Windows Phone emulator executable (for example, C:\Program Files\Microsoft XDE\1.0\XDE.exe). Also ensure that the Web checkbox in the Protocol selection area is checked.
Now create a new Silk Performer project using Web Browser | Silverlight as the application type. The Silverlight project type automatically takes care of encoding and decoding binary data sent to and received from WCF Web Services. This will allow for easy customization of the data later.
Once the project has been created, click Model Script on the Silk Performer workflow bar. From the Workflow – Model Script dialog, choose the previously generated application profile WP7 Emulator.
IMPORTANT: Before starting the recording session, close the Windows Phone emulator.
As soon as the Silk Performer Recorder is running, launch the Windows Phone emulator from Visual Studio. If the recording log contains the following lines, the emulator’s network traffic has been hooked successfully:
Spy DLL initialized ...
Start recording WinSock traffic of application: C:\Program Files (x86)\Microsoft XDE\1.0\XDE.exe
Push the button on the Windows Phone application to call the WCF Web Service and generate network traffic. The Silk Performer Recorder will report and log any newly recorded functions.
Close the Silk Performer Recorder and save the recorded script, which should contain following lines:
"<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:a=\"http://www.w3.org/2005/08/addressing\">\r\n"
" <a:Action s:mustUnderstand=\"1\">urn:Service1/GetTemperatureCelsius</a:Action>\r\n"
" <a:To s:mustUnderstand=\"1\">http://demo.borland.com/WeatherApp/Service1.svc</a:To>\r\n"
" <location xmlns:b=\"http://schemas.datacontract.org/2004/07/WeatherService.Web\" xmlns:i=\http://www.w3.org/2001/
"</s:Envelope>", STRING_COMPLETE, "application/soap+msbin1");
This script can now be replayed by clicking Try Script on the SilkPerformer workflow bar.
Select Results | Explore TrueLog to open Silk Performer TrueLog Explorer.
With TrueLog Explorer, verification statements can be added to the recorded script and data sent to the WCF Web Service can be customized.
After customizing the script, Silk Performer can be used to simulate the expected workloads for the Web Service. With this approach you can verify in advance whether or not the Web Service meets the requirements and service levels required by the mobile application.