收藏 分享(赏)

用LoadRunner测试Web Services 协议.doc

上传人:wspkg9802 文档编号:6820922 上传时间:2019-04-23 格式:DOC 页数:11 大小:323KB
下载 相关 举报
用LoadRunner测试Web Services 协议.doc_第1页
第1页 / 共11页
用LoadRunner测试Web Services 协议.doc_第2页
第2页 / 共11页
用LoadRunner测试Web Services 协议.doc_第3页
第3页 / 共11页
用LoadRunner测试Web Services 协议.doc_第4页
第4页 / 共11页
用LoadRunner测试Web Services 协议.doc_第5页
第5页 / 共11页
点击查看更多>>
资源描述

1、URL: http:/ . ting-in-loadrunner/ 译者: huiguiziran111 原作者:Waldemar 前不久,如何用 Loadrunner 做 webservices 测试 http/html 脚本。现在我想要描述的正确方法-用 Web Services 测试脚本。首先需要一个 web services 网址,并且是可以使用的网址。这是一个 WSDL 的地址:http:/ 我希望 Parasoft 不要介意我使用的 SOAT 测试。另外,我们要有一份 WSDL 文件。现在让我们创造的脚本。点击 新建/从脚本协议中选择 Web Services脚本类型现在,当我们新

2、建一个脚本,都会产生一个新的标准的工具栏。他允许添加 webservice 中描述的脚本文件,可以显示 xml 请求数据和返回的数据。 所以点击 管理服务,接着导入,在 URL 中输入 http:/ 点击 导入接着 WSDL 文件已经导入,直接点击 应用和 确定。在这里 Loadrunner 把 web service引用的参数全部列举。我们准备创建 2 个实际请求数。在工具栏中,实现 2 个操作,一个是“增加呼叫服务” ,另外一个是导出 SOAP点击Add Service Call。在Operation的下拉列表中选择getItemById,在左边的输入参数列表中选择ID 然后在右边的类型的

3、编辑框中输入1我们的脚本如下所示:1. Action()2. 3. web_service_call( “StepName=getItemById_101“,4. “SOAPMethod=Cart|ICart|getItemById“,5. “ResponseParam=response“,6. “Service=Cart“,7. “ExpectedResponse=SoapResult“,8. “Snapshot=t1248415874.inf“,9. BEGIN_ARGUMENTS,10. “id=1“,11. END_ARGUMENTS,12. BEGIN_RESULT,13. END_

4、RESULT,14. LAST);15. return 0;16. 现在我们增加一个 web service 请求导入 SOAP 中。我们假定我们已经在 XML 文件的保存在磁盘中。下面是一个例子:1. 2. 3. 4. Linux5. 6. 7. 点击 “导入 SOAP” 按钮 和选择你的文件。在 Web Service Call (Recommended)中更改 “SOAP Request” 的类型。在清单中选择 URL 和输入 SOAP 路径的值 为“getItemByTitle” 。选择 OK我们添加第二次请求叫做 Linux 的详细说明书。在我们的脚本如下所示:1. Action()

5、2. 3. web_service_call( “StepName=getItemById_101“,4. “SOAPMethod=Cart|ICart|getItemById“,5. “ResponseParam=response“,6. “Service=Cart“,7. “ExpectedResponse=SoapResult“,8. “Snapshot=t1248415874.inf“,9. BEGIN_ARGUMENTS,10. “id=1“,11. END_ARGUMENTS,12. BEGIN_RESULT,13. END_RESULT,14. LAST);15. soap_re

6、quest(“StepName=SOAP Request“,16. “URL=http:/ “SOAPEnvelope=“18. “19. “20. “21. “22. “Linux“23. “24. “25. “,26. “SOAPAction=getItemByTitle“,27. “ResponseParam=response“,28. “Snapshot=t1248416271.inf“,29. LAST);30. return 0;31. 正如你所见的,每个请求都包含在“ResponseParam=response”,LoadRunner 将会自动保存返回到 XMl 的参数化到 表r

7、epose。我们可以得到显示该参数化返回的结果。最后,脚本应该就如下所示:1. lr_message(lr_eval_string(“Response XML is nresponse“);1. Action()2. 3. web_service_call( “StepName=getItemById_101“,4. “SOAPMethod=Cart|ICart|getItemById“,5. “ResponseParam=response“,6. “Service=Cart“,7. “ExpectedResponse=SoapResult“,8. “Snapshot=t1248415874.

8、inf“,9. BEGIN_ARGUMENTS,10. “id=1“,11. END_ARGUMENTS,12. BEGIN_RESULT,13. END_RESULT,14. LAST);15. 16. lr_message(lr_eval_string(“Response XML is nresponse“);17. 18. soap_request(“StepName=SOAP Request“,19. “URL=http:/ “SOAPEnvelope=“21. “22. “23. “24. “25. “Linux“26. “27. “28. “,29. “SOAPAction=get

9、ItemByTitle“,30. “ResponseParam=response“,31. “Snapshot=t1248416271.inf“,32. LAST);33. 34. lr_message(lr_eval_string(“Response XML is nresponse“);35. 36. return 0;37. 最后运行脚本。输出的结果如下所示:【原文:Web Services testing in LoadRunnerSome time ago I described how to test web services in LoadRunner with HTTP/HTM

10、L script. Right now I would like to describe the correct way testing with Web Services script.First of all we need a web services. And there is one available exactly for training. Here is the WSDL http:/ I hope that folks from Parasoft dont mind we are not using SOATest In any case, we have an WSDL

11、file. Now lets create new script. Click File / New and select “Web Services” from list of available scripts types.Now, when we have new script we should see new toolbar under the standard one. It allows to add Web Services description to the script (from WSDL file), add XML request using form and ad

12、d XML request from file. So lets click on “Manage Services” button and then “Import”. Enter WSDL url http:/ and click “Import”.After WSDL file is imported, just click “Apply” and “OK”. From this point LoadRunner has description of our web services so we can use it send some requests. We will actuall

13、y create two requests. One using “Add Service Call” and second using “Import SOAP” buttons from toolbar.Click on “Add Service Call”. In “Operation” dropdown list select value “getItemById”. On left side select “id” under Input Arguments tree node. Then on right side type “1 into Value editbox. Now o

14、ur script should look like this:Action()web_service_call( “StepName=getItemById_101“,“SOAPMethod=Cart|ICart|getItemById“,“ResponseParam=response“,“Service=Cart“,“ExpectedResponse=SoapResult“,“Snapshot=t1248415874.inf“,BEGIN_ARGUMENTS,“id=1“,END_ARGUMENTS,BEGIN_RESULT,END_RESULT,LAST);return 0;Now le

15、ts add Web Service request using Import SOAP. Lets assume we have XML request saved in file on the disk. Here is an example:LinuxClick “Import SOAP” button and select your file. Change type from “Web Service Call (Recommended)” to “SOAP Request”. Select URL from the list, and type into SOAPAction th

16、is value “getItemByTitle”. Click OK.Now weve added second call that ask for book details for title “Linux”. Our script should look like this:Action()web_service_call( “StepName=getItemById_101“,“SOAPMethod=Cart|ICart|getItemById“,“ResponseParam=response“,“Service=Cart“,“ExpectedResponse=SoapResult“,

17、“Snapshot=t1248415874.inf“,BEGIN_ARGUMENTS,“id=1“,END_ARGUMENTS,BEGIN_RESULT,END_RESULT,LAST);soap_request(“StepName=SOAP Request“,“URL=http:/ 0;As you can see, each request contain “ResponseParam=response”. LoadRunner will automatically save response XML into parameter with name “response”. We can

18、easily display this parameter by addind lr_message(lr_eval_string(“Response XML is nresponse“);after each call. So at the end out script should look like this:Action()web_service_call( “StepName=getItemById_101“,“SOAPMethod=Cart|ICart|getItemById“,“ResponseParam=response“,“Service=Cart“,“ExpectedRes

19、ponse=SoapResult“,“Snapshot=t1248415874.inf“,BEGIN_ARGUMENTS,“id=1“,END_ARGUMENTS,BEGIN_RESULT,END_RESULT,LAST);lr_message(lr_eval_string(“Response XML is nresponse“);soap_request(“StepName=SOAP Request“,“URL=http:/ XML is nresponse“);return 0;At the end lets run our script. Output should be something like this:

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报