Web Services performance using LoadRunner HTTP Vuser script
January 24th, 2009
Small (basic) example howto test performance of Web Service using LoadRunner API.
Let say we have a web services that uses SOAP over HTTP. We want to check how fast we can send a request and receive a response. Because our service uses HTTP as a transport protocol, we are able to test it using simple HTTP Vuser script.
Here is the C code:
-
Action()
-
{
-
web_reg_save_param("Response","LB=", "RB=", LAST);
-
web_add_header("SOAPAction", "SampleMethod");
-
lr_start_transaction("REQ");
-
web_custom_request("Sample_Request","Method=POST",
-
"Mode=HTML",
-
"RecContentType=text/xml",
-
"EncType=text/xml; charset=utf-8",
-
"URL=http://example.com:1234/sample/",
-
"Body=<Envelope xmlns=\"http://example.com/sample\">\n"
-
" <Header/>\n"
-
" <Body>\n"
-
" <price><id>001</id></price>\n"
-
" </Body>\n"
-
"</Envelope>",
-
"LAST");
-
lr_end_transaction("REQ", LR_AUTO);
-
lr_output_message("Response is : %s\n", lr_eval_string("{Response}"));
-
return 0;
-
}
Have a fun…

Many people do not realise that they don’t really need a Web Services vuser to test web services, and they can make do by using a standard Web (HTTP/HTML) virtual user.
I wrote a very similar post called Testing Web Services With a Standard Web Vuser.
Cheers,
Stuart.
Yes, thats true. We have to make these people aware
Waldemar
How do you handle authentication if the URL needs user id and password?
Tauhid,
You can setup proxy by using web_set_user() function from LR API.
web_set_user(”domain\\michael”, “abc”, “proxy.example.com:80″);
Waldemar
Hi Waldemar,
Thats really a nice idea I am new to web services protocol, I have created script with SOAP request sucessfully.
As we require Web services license to execute this SOAP request script. I thought of doing it with HTTP/HTML Protocol if possible.
I have tried the way is is given above.
Facing some issues with it can someone help me in this. I am not clear what is “Sample_Request” & “SampleMethod” here in above post.
The URL which we are giving doest open manually in my case that is why I am getting 400 Bad request error. What can I do to resove this solution?
Any sugesstion will be great help for me?
Thanks
Lucky
Have you tried asking your developers? Maybe they can help.
“Sample_Request” is just a step name. You can put here anything.
“SampleMethod” is a method name that you want to call on web service. You should find it in your WSDL file.
Waldemar
Hi Waldemar,
Thanks for your valuable reply.
I have got the informations but in my case the problem is the URL which they have provided not opening up directly through web browser it show 400 error so I am not able to make it sucessful. But I liked this post.
May I have some sample WSDL file so I can practice on it and make myself more comfortable with converting web services into http request.
That will be greate help for me if you can provide me smaple WSDL with all required information as I mentioned in my previous post.
Thanks,
Lucky
Sure,
You can try with web service provided by Parasoft for SOATest tutorial.
Here is the WSDL URL: http://soatest.parasoft.com/store-01.wsdl
And two sample requests:
and
Hi Waldemar,
Thank you very much. I appreciate for you response.
I tried writing script for the same. But no luck for me I am sure I am making some mistake in it. It will greate if you guide me in this. Please have a look on below script.
Action
{
web_add_header(”Content-Type”, “text/xml”);
web_add_header(”SOAPAction”, “\”getItemByTitle\”");
web_add_header(”User-Agent”, “XML Spy”);
web_custom_request(”StepName=getItemByTitle”,
“Method=POST”,
“Mode=HTML”,
“RecContentType=text/xml”,
“EncType=text/xml; charset=utf-8″,
“URL=http://ws1.parasoft.com/glue/store-01″,
“Body= Envelope ”
“xmlns=\”http://schemas.xmlsoap.org/soap/envelope”
“xmlns=\”http://schemas.xmlsoap.org/soap/encoding”
“xmlns:xsi=\”http://www.w3.org/2001/XMLSchema-instance”
“xmlns:xsd=\”http://www.w3.org/2001/XMLSchema”
“”
“”
“xmlns=\”http://www.parasoft.com/wsdl/store-01/>”
“linux”
“”
“”
“”,
LAST);
Thanks,
Lucky
Hi Waldemar,
I apologies some part has got missed out in my earlier post. Please refer this one on behalf of earlier one.
Action( )
{
web_add_header(”Content-Type”, “text/xml”);
web_add_header(”SOAPAction”, “\”getItemByTitle\”");
web_add_header(”User-Agent”, “XML Spy”);
web_custom_request(”StepName=getItemByTitle”,
“Method=POST”,
“Mode=HTML”,
“RecContentType=text/xml”,
“EncType=text/xml; charset=utf-8″,
“URL=http://ws1.parasoft.com/glue/store-01″,
“Body= Envelope”
“xmlns=\”http://schemas.xmlsoap.org/soap/envelope”
“xmlns=\”http://schemas.xmlsoap.org/soap/encoding”
“xmlns:xsi=\”http://www.w3.org/2001/XMLSchema-instance”
“xmlns:xsd=\”http://www.w3.org/2001/XMLSchema”
“”
“”
“xmlns=\”http://www.parasoft.com/wsdl/store-01/>”
“linux”
“”
“”
“”,
LAST);
return 0;
}
Try this:
It works for me. If it doesn’t work for you, then you must have proxy settings missing in LoadRunner.
Hi Waldemar,
Thank you very much for you support. I appereciate your response. It works fine its amazing. It has really enhanced my knowledege on web services scripting.
Thanks
Lucky
No problem
Guys . Im very new at LR , Im using version 9.5. I also have SOA and would like to lear how to test them via regular Web User.
My SOA accept several parameters, so Im listing them in sequence.. I must be doing something very wrong,, when I run the script on Vugen I get :
Action.c(6): HTTP/1.1 500 Internal Server Error\r\n
Action.c(6): Server: Sun-Java-System-Web-Server/7.0\r\n
Action.c(6): Date: Wed, 29 Jul 2009 20:36:14 GMT\r\n
Action.c(6): X-powered-by: Servlet/2.5\r\n
Action.c(6): Content-type: text/xml;charset=”utf-8″\r\n
Action.c(6): Date: Wed, 29 Jul 2009 20:36:11 GMT\r\n
Action.c(6): Transfer-encoding: chunked\r\n
Action.c(6): \r\n
Action.c(6): t=921ms: 5-byte chunked response overhead for “https://192.168.1.203:443/webservice/MyServices” (RelFrameId=1, Internal ID=1)
Action.c(6): 1a0\r\n
Action.c(6): t=929ms: 7-byte chunked response overhead for “https://192.168.1.203:443/webservice/MyServices” (RelFrameId=1, Internal ID=1)
Action.c(6): \r\n
Action.c(6): 0\r\n
Action.c(6): \r\n
Action.c(6): t=958ms: 416-byte chunked response body for “https://192.168.1.203:443/webservice/MyServices” (RelFrameId=1, Internal ID=1)
Action.c(6): ns2:ClientCannot find d
Action.c(6): ispatch method for {https://192.168.1.203:443/webservice/MyServices/}get
Action.c(6): X
Action.c(6): Error -26612: HTTP Status-Code=500 (Internal Server Error) for “https://192.168.1.203:443/webservice/MyServices” [MsgId: MERR-26612]
Action.c(6): Notify: Saving Parameter “Response = HTTP/1.1 500 Internal Server Error\r\nServer: Sun-Java-System-Web-Server/7.0\r\nDate: Wed, 29 Jul 2009 20:36:14 GMT\r\nX-powered-by: Servlet/2.5\r\nContent-type: text/xml;charset=”utf-8″\r\nDate: Wed, 29 Jul 2009 20:36:11 GMT\r\nTransfer-encoding: chunked\r\n\r\nns2:ClientCannot find dispatch method for {https://192.168.1.203:443/webservice/MyServices/}getX”
Action.c(6): t=984ms: Closing connection to 192.168.1.203 after receiving status code 500 [MsgId: MMSG-26000]
Action.c(6): t=992ms: Closed connection to 192.168.1.203:443 after completing 0 requests [MsgId: MMSG-26000]
Action.c(6): t=996ms: Request done “https://192.168.1.203:443/webservice/MyServices” [MsgId: MMSG-26000]
Action.c(6): web_custom_request(”Sample_Request”) highest severity level was “ERROR”, 416 body bytes, 247 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26387]
I think Im writing the Body wrongly.
Anybody seen this before?
Thanks!!
{ and } characters in URL looks like something incorrect.
{https://192.168.1.203:443/webservice/MyServices/}getX
probably should be
https://192.168.1.203:443/webservice/MyServices/getX
That was the answer from the server. My script doesnt have the { } .
Basically what I did was using your script and make some changes according to my WSDL. Like this:
Action()
{
web_reg_save_param(”Response”,”LB=”, “RB=”, LAST);
web_add_header(”SOAPAction”, “getX_101″);
lr_start_transaction(”REQ”);
web_custom_request(”Sample_Request”,
“Method=POST”,
“Mode=HTML”,
“RecContentType=text/xml”,
“EncType=text/xml; charset=utf-8″,
“URL=https://192.168.1.203:443/webservice/Services”,
“Body=”
“”
“”
“”
“user1@gmail.com”
“developer”
“20T70″
“1234567896″
“TLS”
“STANDARD”
“syn”
“1″
“”
“”
“”
“”
“”
“”,
“LAST”);
lr_end_transaction(”REQ”, LR_AUTO);
lr_output_message(”Response is : %s\n”, lr_eval_string(”{Response}”));
return 0;
}
Im sure Im doing something wrong on the script,, but I dont know where, since this is the first time I try it.
Thanks!!!
How can I paste the script here? is chunking my characters.
please use [ code lang="c" ] and [ / code ] to post source code
Sorry, I should warn you. Don’t use spaces. I could not put code tag literally because it will be interpreted.
Obviously I dont know how to use this.
,, Hopefully you can delete all my erroneous junk from your Blog.
Apologies.
in my understanding it should work, drop me an email instead
I sent you the email to the address on this blog,, thanks!!
Hi Waldermar,
It is a nice blog thank you for that, I tried your sample web service script you pasted above (Parasoft Tutorial) and it worked fine . However I have one question that, I have created exactly similar script for the web sevice I want to Load test , I keep getting error.
Action.c(6): Notify: Transaction “REQ” started.
Action.c(7): Error -26612: HTTP Status-Code=500 (Internal Server Error) for “http://sac02v.itutl1.com/Data/pit/pit.asmx” [MsgId: MERR-26612]
Action.c(7): web_custom_request(”Sample_Request”) highest severity level was “ERROR”, 418 body bytes, 238 header bytes [MsgId: MMSG-26388]
Action.c(7): Notify: Transaction “REQ” ended with “Fail” status (Duration: 3.9200 Wasted Time: 0.0000).
Ending action Action.
Pls help me to Debug this issue.
Thanks & Regards,
500 internal server error in most cases means your input values are incorrect. Double check each value, XML tags, etc. Sometimes one space can break whole request.
Waldemar
Hi Waldemar,
New joinee to your site. As you mentioned, we can test web services using HTTP protocol. My application is using both HTTP and web service and a lot of soap request and responses are there in every navigation and data fetch operations.
I tried with HTTP, those step are not at all getting recorded but they are getting recorded with multiprotocol HTTP/web services.
Since we dont have license for web services, I just want to know that if it is really possible to do web services load test using only HTTP protocol with help the coding for large applications also.
Hi Waldemar,
First of all thank you for the reply. I have double checked all the spaces and have re-done it still get 500 server error. Is there any firewall or security concerns blocking by request xml?. I am now also involved in a load testing URL with .svc extension ( WCF WebService) instead of .asmx Can we load test this service using only HTTP/HTML protocol?
Ary:
Yes, it is possible to test web services with HTTP only. But to be honest HTTP and Web Services are two different thinks. HTTP is a transport protocol but Web Service is a software designed in a special way. Web Services communicate using SOAP messages (more details here http://www.w3.org/TR/soap/). But SOAP specification doesn’t define transport protocol. That’s why the easiest way is to use HTTP protocol to send/receive SOAP messages over the network. And most web services use HTTP but there are some that use other transport protocols (JMS for example). So as long as your web service use HTTP to communicate over the network, you should be able to test it using any HTTP client (including LoadRunner HTTP/HTML script).
Sakar2009:
Check if you use any proxy in IE. You can set it in Vuser -> Run-Time settings.
Hi Waldemar,
I have selected obtain proxy settings from default browser under Vuser->RunTime Settings. still get the same Internal Server Rrror – 500.
Hi Waldemar,
Trying to test a WCF webservice with .svc extention using above method of using HTTP Protocol. I am getting HTTP Status-Code=400 message. Pls help me to debug this issue:
Error -26631: HTTP Status-Code=400 (Bad Request) for “http://114.13.9.4/CoBuSHost_FW/FService.svc” [MsgId: MERR-26631]
Action.c(13): Error -26377: No match found for the requested parameter “sessionID”. Check whether the requested boundaries exist in the response data. Also, if the data you want to save exceeds 256 bytes, use web_set_max_html_param_len to increase the parameter size [MsgId: MERR-26377]
Action.c(13): Error -26374: The above “not found” error(s) may be explained by header and body byte counts being 187 and 0, respectively. [MsgId: MERR-26374]
Action.c(13): web_custom_request(”CoService”) highest severity level was “ERROR”, 0 body bytes, 187 header bytes [MsgId: MMSG-26388]
Ending action Action.
sunny2009
Hmmm, probably HTTP header or message body is incorrect. Do you use IIS server to handle web services?
Yes we use IIS server to handle web services, double checked the message body and the string which goes as input XML, not able to get a response from the server.
Hi Waldemar,
I appreciate your response. Thanks.
I tried but not able to record the script using web protocol. But it is recording using web/web service dual protocol and working very well. Please let me know if there is any workaround for doing it using only web protocol. And my UI is silverlight and handling web services using IIS web server.
Using web services protocol, I am able to capture all the requests but I want the reponse time for all the soap request/web service call individually. I mean to say I want the break up of the response time of a transaction in terms of every request. web page diagnostic is not working for web service protocol, I checked. Is there any way for diagnostic?
Hello,
I have a query regarding a mixed approach taken by project. It is a mixed approach of WebMethods and HTTP Post method.
Project is using WebMethods for integration. But it is not using SOAP or WSDL. It is just exposing method. A .NET client is using MSXML2.XMLHTTP40 object to send data (XML) using HTTP POST method.
I have to emulate similar. I tried code to submit data using web_custom_request and web_submit_data. I can login fine using web_set_user. But i receive HTML status code – 403 when code moves to submit request.
Folloing is web_custom_request call: (do note that I have changed certain parameters)
web_custom_request(\"http://WebMethodServer:1000/invoke/ClassName.ClassName.receive/FunctionName\", \"Method=POST\", \"URL=http://wmdevis:6223/invoke/GDTCostarCommon.CostarMPS.receive/mpsDataUpload\" ,\"Mode=HTML\",\"EncType=text/xml; charset=utf-8\",\"Body=<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>DATA\", LAST);
Would you please be able to help.
Regards,
Jigar
Hi Jigar
It can be anything. It’s hard to say. For me it looks ok. But if you have another client that is able to connect there correctly I would start from sniffing the traffic using wireshark.