Web Performance Test
February 5, 2013 Leave a comment
So I decided I wanted to learn more about the testing capabilities of VS2010 – esp. load testing a web service. I fired up Visual Studio and created an out of the box WCF Service with the following 1 method:
public class AddingMachine : IAddingMachine { public int GetData(int value1, int value2) { Random random = new Random(); Int32 delay = random.Next(15); Thread.Sleep(TimeSpan.FromSeconds(delay)); return value1 + value2; } }
I then added a new test project using a Web Performance Test template:
I then hit record, closed IE which automatically popped up, and navigated to the service using the WCF Test Client.
I am sure you are not surprised that nothing was recorded. The problem is that the out of the box Web Performance Test assumes that you are calling a web site so I couldn’t just hit a recording and navigate to a webservice the same way I would navigate to a website.
Instead, I had to right click and add a new web service request. I then changed the Url property to the service location and tried to run the test.
I then binged on Google and ran across a couple of Stack Overflow posts and this nugget on MSDN. Apparently, I need to use Fiddler to capture the request. I fired up Fiddler and WCF Test Client (remember the “.” after local host) and sure enough and can make the call and intercept the traffic:
I copied the entire request from Fiddler:
But I got this when I ran the test I got the same exception. The problem is that the article assumes an .asmx web service and I am using WCF. Digging into the article’s code sample, I realized that I needed a Header like so:
and I needed to put only the body from Fiddler into the String Body property
Fiddler:
WebTest:
And green is good