As per the SOA architecture Web services are often designed that one of them is a consumer of the other. This often leads to scenarios where the output of one service is fed to the other to complete an overall business flow.
The provider and the consumer service can be loaded simultaneously by JMeter and performance of the system can be measured under the expected load.
Let us create an example where we will be passing the output value from the response of the first request to the input SOAP request of the second web service method.
Step 1: Create a test plan
Step 2: Add a Thread Group
Step 3: Add a User Defined Variable
Step 4: Add a WebService Request
Step 5: Add an XPath extractor
Step 6: Add a BeanShell PostProcessor
Step 7: Add Second WebService Request
Step 8: Add View Results Tree
The provider and the consumer service can be loaded simultaneously by JMeter and performance of the system can be measured under the expected load.
Let us create an example where we will be passing the output value from the response of the first request to the input SOAP request of the second web service method.
Step 1: Create a test plan
Step 2: Add a Thread Group
Step 3: Add a User Defined Variable
Step 4: Add a WebService Request
Step 5: Add an XPath extractor
Step 6: Add a BeanShell PostProcessor
Step 7: Add Second WebService Request
Step 8: Add View Results Tree
Step 1: Create a test plan
In the default test plan that appears on opening the JMeter UI (from JMeter.bat in the bin directory) set the option of 'Functional Test Mode' as true. You may also want to add user defined variables. However for this example I will not be using any user defined variable.
Step 2: Add a Thread Group
Add a Thread Group element by right clicking the test plan node and selecting 'Add-->Threads (Users)-->Thread Group'
| Add Thread Group |
You set the loop count to specify how many times do you want each user to hit the web service. If you want to continue loading the web service then you can check the 'Forever' option on the Thread Group element UI.
You can also schedule the load tests by using the 'Scheduler' option provided on the 'Thread Group' UI.
Step 3: Add a User Defined Variable
Right Click on the Thread Group element and select 'Add --> Config Element --> User Defined Variables' to add the 'User Defined Variables' element. On the user defined variables UI screen click on the 'Add' button. Set the 'Name' of the variables and keep the value as blank.
| Add User Defined Variable |
Step 4: Add a WebService Request
Right click on the 'Thread Group' element and select ' Add --> Sampler --> WebService (SOAP) Request'
| Add Web Service Request |
Copy the SOAP request XML in the 'Soap/XML-RPC Data' text box you provide the path of the file in the 'Filename' section.
Step 5: Add an XPath extractor
Right click on the 'Thread Group' element and select ' Add -->Post Processors --> XPath Extractor'
| Add XPath Extractor |
In the Refrence Name section enter the name of the variable that you created in the 'User Defined Variable section'. Enter the XPath query to point to the value which needs to be picked from the XML response. If the value 'TARGET' needs to be picked from the response XML of the format: <ABCD>TARGET</ABCD> then the following XPath query should work:
//*[local-name()='ABCD']/text()
Step 6: Add a BeanShell PostProcessor
Right click on the 'Thread Group' element and select ' Add --> Post Processors --> BeanShell Postpocessor'
| Add BeanShell PostProcessor |
You can print the value of the user defined variable that you created above using the below script written for bean shell:
print("Beanshell processing SOAP response");
print("ACQIDD" +${ACQIDD} );
Here the name of the variable created is "ACQIDD" and the value is fetched from ${ACQIDD}.
You can see the value of the variable printed on the command screen that was used to launch the JMeter UI.
Step 7: Add Second WebService Request
Add another webservice request to your thread group element and pass the value of the user defined variable to the input request using the following format:
<value>${ACQIDD}</value>
Step 8: Add View Results Tree
Add a result tree element to the thread group to view the results of the web service requests. After adding the element you can save and run the test plan to see that the output of one SOAP request is read to extract the required value. This value is then passed to another SOAP request. The result tree looks something like this:
| Results Tree |