简体   繁体   中英

send restful request by Jmeter

I have a restful request and I need to send it to a webservice using Jmeter. 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:

Thread Group SOAP/XML-RPC Request 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 ds.JMeterThread.process_sampler(JMeterThread.java:428) at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256) at java.lang.Thread.run(Unknown Source)

  1. You need to use HTTP Request Sampler for sending REST requests, the JSON payload needs to go into "Body Data" tab like:

    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
  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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