Parameter Extraction in Web Application Synthetic Transactions In Operations Manager R2 CU3 we added a new feature that expands our capabilities in monitoring web applications via synthetic transactions. Parameter extraction allows us to extract data from the HTTP responses to web requests and store the value in the test context as name value pairs which can then be reused in subsequent requests within the test context. Some extraction examples include extracting a session ID from a hidden form field, an order number from a checkout page, or even a dynamically generated link that will be navigated to later in the synthetic transaction. When you record a web application synthetic transaction via our browser recorder we capture the actual requests that were made and then attempt to play these requests back when running the synthetic transaction. This works in most cases but fails when we capture session specific information that changes every time the synthetic transaction runs meaning what you recorded is now out of date. Let’s say you have a recorded a test sequence like the below: Step 1: http://www.myapp.com/home.aspx Step 2: http://www.myapp.com/search.aspx?query=testing&sessionid=32793279321721 Step 3: http://www.myapp.com/results.aspx?sessionid=32793279321721 In this example sessionid is used by the application to identify a specific user for the duration of that user’s visit. Since sessionids are usually short-lived (this will expire after a period of inactivity) when we play back the request it will fail as the sessionid is no longer valid. In order for this test to work we can use parameter extraction to make the sessionid a parameter. When we get the HTTP response from Step 1 it contains the sessionid so we create a parameter for this and a way to determine how to find it. (This is the hard part and I will provide some example later in this document). The test then looks like this: Step 1: http://www.myapp.com/home.aspx (look in HTTP response for “sessionid=” and add value to parameter named newsessionid) Step 2: http://www.myapp.com/search.aspx?query=testing&sessionid=$newsessionid$ Step 3: http://www.myapp.com/results.aspx?sessionid=$newsessionid$ Now when the test runs we use the actual sessionid and the test will succeed. A good free tool to use to understand and see HTTP request and responses is Fiddler : http://www.fiddler2.com/fiddler2/ Example 1: Testing SQL Reporting Services reports In this example I will walk you through how you can create synthetic transactions to run SQL reporting services reports. This example could be used to measure the health and availability of your Operations Manager data warehouse by running reports and checking the data was retrieved from the DW and rendered in the report. Prerequisites: 1. Run a report in the Operations Manager console and save the report to a management pack. For instructions on how to do this: http://technet.microsoft.com/en-us/library/ee292082.aspx 2. This creates a version of the report that can be run without parameter entry. 3. Navigate to the SQL reporting services web application (http://<localhost>/reportserver) and test this report to confirm it renders correctly. In my example I have used the Availability report targeted at my RMS as I know this should always return data. Once this is done you can now record your Synthetic Transaction. See http://technet.microsoft.com/enus/library/dd440885.aspx for details. After recording you should have a request sequence that looks like this: In this transaction when you run step 3(clicking on the report) there are 3 values that need to be extracted to ensure the last 3 steps can be run correctly these are: ReportURL ExecutionID ControlID Note: If you want to see/understand the HTTP responses you could use Fiddler and capture the same transaction. I will be covering more scenarios and understanding requests and responses in further blogs. We need to create parameters for these. Select step 3(or the step that ends with Command=Render) and select properties for the request. Go to the Extraction Rules tab as shown below (If you do not see this TAB then CU3 is not installed) Click add and the following screen is shown: Enter the context parameter name as ReportURL Enter starts with as &amp;ReportUrl= Enter ends with as “ Then click OK to save. Now do the same for ExecutionID and ControlID with the following values: Click Apply once complete. We now need to use these parameters in the subsequent requests. Open the properties of the next request and then click Insert parameter below the Request URL Place your cursor after &ReportURL= in the String box: Delete everything after &ReportURL=: Highlight the ReportsURL from the Parameters list and then click Insert: This request is now complete click Apply then Ok Open the properties of the next request and update the Request URL to replace the values for ExecutionID and ControlID with the Parameters. String should be like the following: localhost/ReportServer/Reserved.ReportViewerWebControl.axd?ExecutionID=$ParametersContext/Exe cutionID$&ControlID=$ParametersContext/ControlID$&Culture=1033&UICulture=9&ReportStack=1&O pType=SessionKeepAlive&TimerMethod=KeepAliveMethodReportViewerControlTouchSession0&CacheS eed=Thu%20Oct%2007%2017%3A35%3A30%202010 Once complete click Apply then Ok Finally open the properties of the last request and once again update the Request URL to replace the values for ExecutionID and ControlID. String should be like the following: localhost/ReportServer/Reserved.ReportViewerWebControl.axd?ExecutionID=$ParametersContext/Exe cutionID$&ControlID=$ParametersContext/ExecutionID$&Culture=1033&UICulture=9&ReportStack=1 &OpType=ReportArea&Controller=ReportViewerControl&PageNumber=1&ZoomMode=Percent&ZoomP ct=100&ReloadDocMap=true&SearchStartPage=0&PageCountMode=Estimate&LinkTarget=_top Once complete click Apply then Ok This is now complete and you can save and run the Synthetic Transaction once you have configured the required monitoring. To validate the report renders correctly you could create a content match criteria to look for specific text on the rendered report as shown below. (The last request should be the rendered report and where you want to add the criteria.