0
votes

I'm trying to create the script for WSDL soap services and my requirement is i want to print points response output parameter value into a csv results file using Beanshell Postporcessor.

Below is the response of SOAP.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soap:Body>
      <CardResponse xmlns="http://service.clp.eks.com">
         <out>
            <birthDate xmlns="http://wsform.clp.eks.com">05-04-00</birthDate>
            <cardno xsi:nil="true" xmlns="http://wsform.clp.eks.com"/>
            <customerName xmlns="http://wsform.clp.eks.com">krishna singhji</customerName>
            <flag xmlns="http://wsform.clp.eks.com">TRUE</flag>
            <memberLevel xsi:nil="true" xmlns="http://wsform.clp.eks.com"/>
            <points xmlns="http://wsform.clp.eks.com">**500.0**</points>
            <reason xsi:nil="true" xmlns="http://wsform.clp.eks.com"/>
         </out>
      </CardResponse>
   </soap:Body>
</soap:Envelope>

My Beanshell Script is :

import java.io.File;
import org.apache.jmeter.services.FileServer;

CardNo =vars.get("cardno");

Result = "FAIL";
Response = prev.getResponseDataAsString();

if(Response.contains("TRUE"))
    Result = "PASS";
Points = vars.get("points");

f = new FileOutputStream("F:\\Java_Applications\\apache-jmeter-3.1\\bin\\CardsResults.csv",true);
p=new PrintStream(f);

this.interpreter.setOut(p);

p.println(CardNo + "," + Points + "," + Result);
f.close();

After running the TestPlan my results file not displaying value for points and displaying as null value,Please help me how to resolve this issue.ASAP

1

1 Answers

0
votes

Your script looks more or less OK so the problem seems to be with the ${points} JMeter Variable.

If you set it somewhere before your Beanshell script - double check this place where you define it and double check the expected value using Debug Sampler and View Results Tree Listener combination.

If you don't extract this ${points} variable - you need to do this before the Beanshell PostProcessor i.e. using XPath Extractor configured like:

  • Reference Name: points
  • XPath query: //points

XPath Extractor Configuration

XPath Tester Demo

And make sure you put XPath Extractor before the Beanshell PostProcessor.


Going forward consider using JSR223 PostProcessor and Groovy language instead of Beanshell, it is more performing scripting option.