1

I am using Jmeter-2.6 for Load testing,

I need to pass query parameters to web services,i did the following

  • Added a Thread Group
  • Added Http Request

In Http Request,i have provided

  • Protocol-http

  • Method-post

  • Content Encoding - utf-8

i checked Redirect Automatic and Use KeepAlive options Path for web service.

and i have added the query parameters in Send Parameters with Request Section as follows

Name Value

name ABC Web service

but the value for name is null in web service,ie the value is not passed to the web service.How to pass the query parameter value to web service from Jmeter.Is it possible to send Query parameters to POST method.

Community
  • 1
  • 1
user1321824
  • 445
  • 3
  • 22
  • 41
  • What kind of web service are you calling? I did a quick test with the parameters you used, and with `nc -l someLocalPort` and it works as expected. – Carlo Apr 20 '12 at 07:40
  • i m using Restful web servvice – user1321824 Apr 20 '12 at 07:43
  • Can you try this? Open a terminal, type nc -l 8888, run the jmeter test against localhost 8888. Do you see the expected parameters? – Carlo Apr 20 '12 at 08:14
  • I ran the test as u mentioned but i couldn't able see the parameters and its corresponding values.Is it possible only to pass Formparam in POST method,not QueryPAram.?? – user1321824 Apr 20 '12 at 08:44
  • Form parameters are the same thing as the query parameters. This is my Http request sampler: http://cl.ly/3y1e472c3c1m2h0y2n3L If you can't find any differences, you might wanna update your test case somewhere, so I can give it a look. – Carlo Apr 20 '12 at 08:58
  • @user1321824 did you test to add these query parameters directly in Path field as a normal URL `/my-rest-service?param1=${value1}&param2=${value2}` ? – Flavio Cysne Jul 18 '12 at 14:12
  • 1
    @Carlo Form parameters aren't the same of query parameters. Form parameter go into request's body (POST Data) and Query parameters go on URL. See this related question [HTTP POST with URL query parameters — good idea or not?](http://stackoverflow.com/questions/611906/http-post-with-url-query-parameters-good-idea-or-not). – Flavio Cysne Jul 20 '12 at 13:04
  • Ok, thank you very much. I wasn't aware of the different name for the two things. – Carlo Jul 24 '12 at 07:08

2 Answers2

0

Suppose you have this type of REST resource implemented in Java:

@Path("/sample")
public class SampleResource {
    @Context UriInfo uriInfo;

    @POST
    @Path("/")
    @Produces("text/plain")
    public String postWithQueryParameters(@QueryParam("param1") String param1, @QueryParam("param2") String param2) {
        System.out.println("param1=" + param1 + "&param2=" + param2);
        return "success";
    }
}

In your JMeter Test Plan you can add an HTTP Request with, at least, these settings:

Method: POST
Path: /my-rest-service/sample?param1=${value1}&param2=${value2}
Flavio Cysne
  • 1,436
  • 8
  • 8
0

Create a Thread group in test module, After that add Logic controller -> loop controller. in loop controller we have to add httprequest from add->sampler->httprequest. in httprequest we have the parameter tab u just mention the values what u want to pass to your application