How To: Use ACT to Test Web Services Performance
Retired Content |
---|
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
J.D. Meier, Srinath Vasireddy, Ashish Babbar, and Alex Mackman
Microsoft Corporation
May 2004
Related Links
Home Page for Improving .NET Application Performance and Scalability
Chapter 15, Measuring .NET Application Performance
Chapter 16, Testing .NET Application Performance
How To: Use ACT to Test Web Services Performance
Send feedback to Scale@microsoft.com
Summary: Microsoft® Application Center Test (ACT) does not directly support the testing of Web services, so you must manually modify your test scripts to make the tool work correctly. This How To walks you through the creation of an ACT test script file that you can use to load test a Web service.
Summary of Steps
Step 1. Create an Empty ACT Test
Step 2. Create the SOAP Request
Step 3. Copy the SOAP Envelope to the Test Script File
Step 4. Modify the SOAP Envelope
Step 5. Add Request Headers to the Test File
Step 6. Add Send Request to Complete the Test File
Final Test Script
Sample: Simple Web Service
.NET Framework Version 1.1 Considerations
Additional Resources
- Microsoft Application Center Test (ACT). This tool is included with Microsoft Visual Studio®.NET Enterprise Developer and Enterprise Architect Editions.
- Microsoft .NET Framework versions 1.0 and 1.1.
ACT is designed for stress testing Web servers and analyzing performance and scalability problems with Web applications. Visual Studio .NET Enterprise Developer and Enterprise Architect Editions include ACT. You can use ACT directly within the integrated development environment (IDE), though this method provides limited project configuration options. Full options are available only when you use the stand-alone ACT application.
ACT does not directly support the testing of Web services, so you must manually modify your test scripts to make the tool work correctly. This How To walks you through the creation of an ACT test script file that you can use to load test a Web service. The sample code for the Web service used in this example is available in "Sample: Simple Web Service" later in this How To.
This How To includes the following steps:
- Create an empty ACT test.
- Create the SOAP request.
- Copy the SOAP envelope to the test script file.
- Modify the SOAP envelope.
- Add request headers to the test file.
- Add Send Request to complete the test file.
In this step, you create an empty ACT test named ACTTest.
To create an empty test
- Start ACT. In the Actions dialog box, click New Test.
- In the Welcome dialog box, click Next.
- In the Test Source dialog box, click Create an empty test, and then click Next.
- Click Next.
- In the Test name field, type a name for the test (in this case, ACTTest).
- Click Next, and then click Finish.
Invoke the Web service from Microsoft Internet Explorer® by entering the path of the Web service to be tested. Then select the Web method you want to test. A Web service Help page is displayed that contains the following sample SOAP request and response.
POST /HelloTest/WS/ACTSampleWS.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/Hello"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Hello xmlns="http://tempuri.org/" />
</soap:Body>
</soap:Envelope>
Copy the entire SOAP envelope from the browser window to the Clipboard, and then paste it into your test script as follows.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Hello xmlns="http://tempuri.org/" />
</soap:Body>
</soap:Envelope>
You need to modify the SOAP envelope in two ways:
- Replace double quotation marks with"& chr(34) &" in the copied SOAP envelope.
- Convert the SOAP envelope to a request body.
You need to replace the double quotation marks with "& chr(34) &". You can use the ACT Replace menu item to automate this task.
To replace double quotation marks by using ACT
On the Edit menu, click Replace.
In the Findwhat edit box, add one double quotation mark ( " ).
In the Replacewith edit box, type "& chr(34) & ", including quotation marks on each side.
Click Replace All.
Note that there is no undo option for this action.
You need to add Body = " to the first line (make sure that there are no spaces after the double quotation marks) and Body = Body & " to all of the following lines of the modified SOAP envelope. Also, add a quotation mark at the end of each line of the SOAP request.
After you've made these two modifications, the SOAP envelope looks like the following.
Body = "<?xml version="&chr(34)&"1.0"&chr(34)&" encoding="&chr(34)&"utf-8"&chr(34)&"?>"
Body = Body & "<soap:Envelope xmlns:xsi="&chr(34)&"http://www.w3.org/2001/XMLSchema-instance"&chr(34)&" xmlns:xsd="&chr(34)&"http://www.w3.org/2001/XMLSchema"&chr(34)&" xmlns:soap="&chr(34)&"https://schemas.xmlsoap.org/soap/envelope/"&chr(34)&">"
Body = Body & "<soap:Body>"
Body = Body & "<Hello xmlns="&chr(34)&"http://tempuri.org/"&chr(34)&" />"
Body = Body & "</soap:Body>"
Body = Body & "</soap:Envelope>"
Add the following code to the beginning of the test script. Place this code immediately before the SOAP request you pasted into the test.
Dim oConnection
Dim oRequest
Dim oRepsonse
set oConnection = Test.CreateConnection("<Web Server Name Here>", 80, false)
set oRequest = Test.CreateRequest
oRequest.Path = "<Web Service Path Here>"
oRequest.Verb = "POST"
oRequest.HTTPVersion = "HTTP/1.1"
oRequest.Headers.RemoveAll
oRequest.Headers.Add "Host", "(automatic)"
oRequest.Headers.Add "SOAPAction", "<Web Service Namespace here>"
oRequest.Headers.Add "Content-Type", "text/xml; charset=utf-8"
oRequest.Headers.Add "Content-Length", "(automatic)"
Note You must replace <Web Service Path Here> with your Web service path, and you must replace <Web Service Namespace here> with your Web service namespace.
Obtain the Web service path from the generated output that is displayed in the browser. Sample output is shown here. Use the Web service path from the POST line of the request.
POST /HelloTest/WS/ACTSampleWS.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/Hello"
The path for this sample is /HelloTest/WS/ACTSampleWS.asmx.
Obtain the Web service namespace from the generated output displayed in the browser. Copy the Web service path from the SOAPAction: line of the request.
oRequest.Headers.Add "SOAPAction", "http://tempuri.org/Hello"
The path for this sample is http://tempuri.org/Hello.
Add the following code to send the request to the end of the script file.
oRequest.Body = Body
Set oResponse = oConnection.Send(oRequest)
The following example shows a test script after the modifications discussed in this How To have been applied. This script is suitable for testing a Web service.
Dim oConnection
Dim oRequest
Dim oRepsonse
set oConnection = Test.CreateConnection("localhost", 80, false)
set oRequest = Test.CreateRequest
oRequest.Path = "/HelloTest/WS/ACTSampleWs.asmx"
oRequest.Verb = "POST"
oRequest.HTTPVersion = "HTTP/1.1"
oRequest.Headers.RemoveAll
oRequest.Headers.Add "Host", "(automatic)"
oRequest.Headers.Add "SOAPAction", "http://tempuri.org/Hello"
oRequest.Headers.Add "Content-Type", "text/xml; charset=utf-8"
oRequest.Headers.Add "Content-Length", "(automatic)"
Body = "<?xml version="&chr(34)&"1.0"&chr(34)&" encoding="&chr(34)&"utf-8"&chr(34)&"?>"
Body = Body & "<soap:Envelope xmlns:xsi="&chr(34)&"http://www.w3.org/2001/XMLSchema-instance"&chr(34)&" xmlns:xsd="&chr(34)&"http://www.w3.org/2001/XMLSchema"&chr(34)&" xmlns:soap="&chr(34)&"https://schemas.xmlsoap.org/soap/envelope/"&chr(34)&">"
Body = Body & "<soap:Body>"
Body = Body & "<Hello xmlns="&chr(34)&"http://tempuri.org/"&chr(34)&" />"
Body = Body & "</soap:Body>"
Body = Body & "</soap:Envelope>"
oRequest.Body = Body
Set oResponse = oConnection.Send(oRequest)
The following simple Web service code returns a "Hello World" string when the "Hello" Web method is called. You can use this sample to check that your ACT test script functions correctly.
SampleWS.asmx
<%@ webservice language=c# class=SampleWS.HelloWorld %>
using System.Web.Services;
namespace SampleWS
{
public class HelloWorld
{
[WebMethod]
public string Hello()
{
return "Hello World";
}
}
}
.NET Web services support HTTP GET, HTTP POST, and SOAP protocols. By default, in .NET Framework 1.1, HTTP GET and HTTP POST are both disabled.
You can enable the HTTP GET and HTTP POST protocols either for a specific Web service using Web.config or for the entire computer using Machine.config.
Use the following configuration in a specific Web.config file in the virtual root directory where the Web service resides. The following configuration enables both HTTP GET and HTTP POST.
<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
</configuration>
The following example enables HTTP GET, HTTP POST, and SOAP; it also enables HTTP POST for requests from localhost.
<protocols>
<add name="HttpSoap"/>
<add name="HttpPost"/>
<add name="HttpGet"/>
<add name="HttpPostLocalhost"/>
</protocols>
For more information about enabling these protocols, see Knowledge Base article 819267, "INFO: HTTP GET and HTTP POST Are Disabled by Default" at https://support.microsoft.com/default.aspx?scid=kb;en-us;819267.
For more information, see the following resources:
- For information about using ACT for load testing and stress testing, see "How To: Use ACT to Test Performance and Scalability" in the "How To" section of this guide.
- Chapter 15, "Measuring .NET Application Performance."
- Chapter 16, "Testing .NET Application Performance."
- For detailed information about ACT, see "Microsoft Application Center Test 1.0, Visual Studio .NET Edition" on MSDN® at https://msdn.microsoft.com/en-us/library/aa287410(VS.71).aspx.
- Performance Testing Microsoft .NET Web Applications, available from Microsoft Press® at https://www.microsoft.com/MSPress/books/5788.aspx.
Retired Content |
---|
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |