简体   繁体   English

通过Jmeter发送宁静的请求

[英]send restful request by Jmeter

I have a restful request and I need to send it to a webservice using Jmeter. 我有一个烦躁的请求,需要使用Jmeter将其发送到Web服务。 here is my reuest: 这是我的要求:

{"type":"CustomerProfileReqModel","messageCode":"GetCustRq","messageVersion":"V1.0","language":"en-gb","recieverCode":"newone","customerModel":{"userName":"load24","password":"P@ssw0rd","categoryCode":"NORM"},"uiCacheVersion":"3e096b72-ed40-4f8a-aad3-9ed52a4aa8ba"}

And here is what I created in JMeter: 这是我在JMeter中创建的:

Thread Group SOAP/XML-RPC Request URL: http://localhost:9000/MyFawryWeb/rest/MFServlet/service 线程组SOAP / XML-RPC请求URL: http:// localhost:9000 / MyFawryWeb / rest / MFServlet / service

When I run I got the below error: 当我运行时,出现以下错误:

org.apache.commons.httpclient.NoHttpResponseException: The server 11.92.0.91 failed to respond at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1976) at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735) at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) at org.apache.jmeter.protocol.http.sampler.SoapSampler.sample(SoapSampler.java:271) at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1088) at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1077) at org.apache.jmeter.threa org.apache.commons.httpclient.NoHttpResponseException:服务器11.92.0.91无法通过org.apache.commons.httpclient.HttpMethodBase.readResponse( org.apache.commons.httpclient上的HttpMethodBase.java:1735)org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)上的org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098) org.apache.commons上的.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171).org.apache.commons.httpclient.Httpclient.HttpClient.executeMethod(HttpClient.java:323 )的org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1088)的org.apache.jmeter.protocol.http.sampler.SoapSampler.sample(SoapSampler.java:271) org.apache.jmeter.threa上的apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1077) ds.JMeterThread.process_sampler(JMeterThread.java:428) at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256) at java.lang.Thread.run(Unknown Source) org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)处的ds.JMeterThread.process_sampler(JMeterThread.java:428)(java.lang.Thread.run(未知源)

  1. You need to use HTTP Request Sampler for sending REST requests, the JSON payload needs to go into "Body Data" tab like: 您需要使用HTTP Request Sampler发送REST请求,JSON有效负载需要进入“ Body Data”标签,例如:

    JMeter REST请求

  2. I believe you should also be adding a HTTP Header Manager and configure it to send Content-Type header with the value of application/json 我相信您还应该添加一个HTTP Header Manager并将其配置为发送带有application/json值的Content-Type标头
  3. Add View Results Tree listener to inspect request and response details and run your request (don't forget to remove it when it comes to running load test with increased number of users) 添加“ 查看结果树”侦听器以检查请求和响应详细信息并运行您的请求(在运行带有大量用户的负载测试时,请不要忘记删除它)

See REST API Testing - How to Do it Right for more information and detailed instructions. 有关更多信息和详细说明,请参阅REST API测试-如何正确进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM