通过Jmeter

时间:2017-07-13 10:55:00

标签: apache xmlhttprequest jmeter load restful-url

我有一个宁静的请求,我需要使用Jmeter将其发送到Web服务。 这是我的回应:

{"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"}

以下是我在JMeter中创建的内容:

线程组 SOAP / XML-RPC请求 网址:http://localhost:9000/MyFawryWeb/rest/MFServlet/service

当我跑步时,我收到以下错误:

  

org.apache.commons.httpclient.NoHttpResponseException:服务器11.92.0.91无法响应       在org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1976)       在org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)       在org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)       在org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)       在org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)       在org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)       在org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)       在org.apache.jmeter.protocol.http.sampler.SoapSampler.sample(SoapSampler.java:271)       在org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1088)       at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1077)       在org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:428)       在org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)       在java.lang.Thread.run(未知来源)

1 个答案:

答案 0 :(得分:0)

  1. 您需要使用HTTP Request Sampler发送REST请求,JSON有效负载需要进入“正文数据”标签,如:

    JMeter REST Request

  2. 我相信您还应添加HTTP Header Manager并将其配置为发送Content-Type header,其值为application/json
  3. 添加View Results Tree侦听器以检查请求和响应详细信息并运行您的请求(在运行带有更多用户的负载测试时不要忘记将其删除)
  4. 有关详细信息和详细说明,请参阅REST API Testing - How to Do it Right