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:
- Use Fiddler to capture HTTP requests
- Use the captured information to define requests in a web test
- Add Extraction Rules to the invocation request
- Substitute context variables in the postback bodys
- Add an Extraction Rule to the postback requests
Use Fiddler to capture HTTP requests
- Start Fiddler

- Start capturing
- Open an InfoPath form in a web browser

- Perform the actions you want to happen in your test

Use the captured information to define requests in a web test
- Start Visual Studio
- Create a new web test
- 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.)
- From the fiddler capture, find the GET request for /_layouts/FormServer.aspx

- Add that request to the web test

- Find the postbacks which are POST requests for /_layouts/Postback.FormServer.aspx or /_layouts/FormServer.aspx

- 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.

Add Extraction Rules to the invocation request
- In the web test, find the first request for /_layouts/FormServer.aspx
- Add ExtractEditingSessionId, ExtractSolutionId, and ExtractInitialCanary extraction rules
Substitute context variables in the postback bodys
- In the web test, find the postback requests
- In its string body, find the event log
- For partial postbacks, the event log will be the only data in the string body
- For full page postbacks, the text __EventLog should precede the section containing the event log
- Edit the EventLogInfo of the postback body as follows:
- Replace the 3rd item with {{editingSessionId}}
- Replace the 4th item with {{solutionId}}
- Replace the 19th item with {{canary}}
Add an Extraction Rule to the postback requests
- In the web test, find the postback requests
- Add ExtractPostbackCanary extraction rule to each of these requests
Once you have followed these steps, your web test should resemble the following picture.
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.