用LoadRunner测试Web Services 协议.doc_第1页
用LoadRunner测试Web Services 协议.doc_第2页
用LoadRunner测试Web Services 协议.doc_第3页
用LoadRunner测试Web Services 协议.doc_第4页
用LoadRunner测试Web Services 协议.doc_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

URL: / . ting-in-loadrunner/译者: huiguiziran111 原作者:Waldemar 前不久,如何用Loadrunner做webservices测试http/html脚本。现在我想要描述的正确方法-用Web Services测试脚本。首先需要一个web services 网址,并且是可以使用的网址。这是一个WSDL的地址:/store-01.wsdl 我希望Parasoft 不要介意我使用的SOAT 测试。另外,我们要有一份WSDL文件。现在让我们创造的脚本。点击 新建/从脚本协议中选择 Web Services脚本类型现在,当我们新建一个脚本,都会产生一个新的标准的工具栏。他允许添加webservice中描述的脚本文件,可以显示xml请求数据和返回的数据。 所以点击 管理服务,接着导入,在URL中输入 /store-01.wsdl, 点击 导入接着 WSDL 文件已经导入,直接点击 应用和确定。在这里Loadrunner把web service引用的参数全部列举。我们准备创建2个实际请求数。在工具栏中,实现2个操作,一个是“增加呼叫服务”,另外一个是导出 SOAP点击Add Service Call。在Operation的下拉列表中选择getItemById,在左边的输入参数列表中选择ID 然后在右边的类型的编辑框中输入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_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()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_request(StepName=SOAP Request,16. URL=/glue/store-01,17. SOAPEnvelope=18. 19. 20. 21. 22. Linux23. 24. 25. ,26. SOAPAction=getItemByTitle,27. ResponseParam=response,28. Snapshot=t1248416271.inf,29. LAST);30. return 0;31. 正如你所见的,每个请求都包含在“ResponseParam=response”,LoadRunner将会自动保存返回到XMl的参数化到 表repose。我们可以得到显示该参数化返回的结果。最后,脚本应该就如下所示: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.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=/glue/store-01,20. SOAPEnvelope=21. 22. 23. 24. 25. Linux26. 27. 28. ,29. SOAPAction=getItemByTitle,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/HTML 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 /store-01.wsdl. I hope that folks from Parasoft dont mind we are not using SOATestIn any case, we have an WSDL 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 add XML request from file. So lets click on “Manage Services” button and then “Import”. Enter WSDL url /store-01.wsdl 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 actually 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 our 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 lets 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 this 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, Snapshot=t1248415874.inf, BEGIN_ARGUMENTS, id=1, END_ARGUMENTS, BEGIN_RESULT, END_RESULT, LAST); soap_request(StepName=SOAP Request, URL=/glue/store-01, SOAPEnvelope= Linux , SOAPAction=getItemByTitle, ResponseParam=response, Snapshot=t1248416271.inf, LAST); return 0;As you can see, each request contain “ResponseParam=response”. LoadRunner will automatically save response XML into parameter with name “response”. We can 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() we

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论