0
votes

I am trying to test web service for my project. The Web service accepts a SOAP request and gives appropriate response.

In JMeter I have chosen SOAP/ XML-RPC request. It works completely fine for me and gives me correct response. However, I have more than 100s of web services in my scope of testing and I have to test them in different environments. It is very cumbersome work to change the URL value from the SOAP/ XML-RPC sample to point it to different env. Do we have something like HTTP Request Default for SOAP/XML-RPC requests?

I have also tried a bean shell sampler where I am setting the value of a variable and then retrieve it in the SOAP sampler URL parameter. However it did not work for me. Below is the code.

Bean Shell sampler code: vars.put("baseURL","http://localhost:9191/ws/soap");

SOAP/ XML-RPS Sampler URL value: ${__BeanShell(vars.get("baseURL"))}

Any suggestions? I read in JMeter docs that this can be done via http sampler, however, I want to avoid using the same if possible.

2

2 Answers

1
votes

Use JMeter Properties to set base url like:

  • in user.properties file (under /bin folder of your JMeter installation) add one line per property:

    baseURL=http://localhost:9191/ws/soap
    
  • alternatively you can pass the property via -J command line key as:

    jmeter -JbaseURL=http://localhost:9191/ws/soap -n -t /path/to/your/testplan.jmx -l /path/to/results.jtl
    

Refer the defined property in your test plan using __P() function

${__P(baseURL,)}

You can even provide the default value, i.e. if the property is not set via user.properties file or command-line argument - default value will be used:

${__P(baseURL,http://localhost:9191/ws/soap)}

See Apache JMeter Properties Customization Guide for more information on JMeter properties and ways of setting, overriding and using them.

2
votes

You should avoid using SOAP/XML-RPC in favor of pure Http Sampler. Use the "Templates..." (menu) > Building a SOAP Webservice Test Plan:

enter image description here

enter image description here

This way you can use HTTP Request Default if you want.

But note from what you describe, using a CSV Data Set Config would allow you to variabilize the URL.