Putting the Pieces together in Visual Studio

Now that we have a general idea how IPFS generates HTTP traffic, we can write a web test in Visual Studio. Let’s recap the relevant IPFS architecture information:
  • IPFS has two main transactions when interacting with a form: Invocation and Postback
  • Editing Session Id, Solution Id, and Canary are dynamic. They will need to be extracted from responses.
  • Editing Session Id, Solution Id, and Canary are used in the postback request. Their values will need to be substituted in the postback body.
  • Editing Session Id and Solution Id do not change between postbacks. They will only need to be extracted for the invocation request.
  • Canary changes after every postback. It needs to be extracted for every request.
We have all the required knowledge; we just need to put the pieces together. The basic steps to write a web test for IPFS are:
  1. Use Fiddler to capture HTTP requests
  2. Use the captured information to define requests in a web test
  3. Add Extraction Rules to the invocation request
  4. Substitute context variables in the postback bodys
  5. Add an Extraction Rule to the postback requests

Use Fiddler to capture HTTP requests

  1. Start Fiddler start fiddler.jpg
  2. Start capturing
  3. Open an InfoPath form in a web browser open form.jpg
  4. Perform the actions you want to happen in your test perform actions in browser.jpg

Use the captured information to define requests in a web test

  1. Start Visual Studio
  2. Create a new web test
  3. Add an InfoPathExtractionRules reference to the test project. (You can download a dll for InfoPathExtractionRules from the Releases tab of this project. Or you can download the source code for those rules on the Source Code tab.)
  4. From the fiddler capture, find the GET request for /_layouts/FormServer.aspx fiddler invocation selected.jpg
  5. Add that request to the web test create invocation request.jpg
  6. Find the postbacks which are POST requests for /_layouts/Postback.FormServer.aspx or /_layouts/FormServer.aspx fiddler postback selected.jpg
  7. Add those postback requests to the web test as web service requests. Be sure to copy the postback body. The eventlog string should end with a single space. Double check that the event log you copied to the webtest ends with a single space as this is a common mistake. create postback request.jpg

Add Extraction Rules to the invocation request

  1. In the web test, find the first request for /_layouts/FormServer.aspx
  2. Add ExtractEditingSessionId, ExtractSolutionId, and ExtractInitialCanary extraction rules

Substitute context variables in the postback bodys

  1. In the web test, find the postback requests
  2. In its string body, find the event log
    1. For partial postbacks, the event log will be the only data in the string body
    2. For full page postbacks, the text __EventLog should precede the section containing the event log
  3. Edit the EventLogInfo of the postback body as follows:
    1. Replace the 3rd item with {{editingSessionId}}
    2. Replace the 4th item with {{solutionId}}
    3. Replace the 19th item with {{canary}}
postback substitute.jpg

Add an Extraction Rule to the postback requests

  1. In the web test, find the postback requests
  2. Add ExtractPostbackCanary extraction rule to each of these requests

Once you have followed these steps, your web test should resemble the following picture.
complete webtest.jpg

IpfsWebtestAutoFixer Tool

IpfsWebtestAutoFixer is tool which makes creating an InfoPath web test much easier. It automatically adds the appropriate extraction rules to the invocation request and postback requests. It also automatically substitutes context parameters in postback bodys.

Last edited Jul 24, 2008 at 9:39 PM by JBooze, version 1

Comments

No comments yet.