Above is my code i have written to hit a web service whose endpoint is expecting a Byte Stream object. I am able to do that but i am not getting any response. I have to test the response. Though i am getting 200 ok but a string is sent in response that i am not getting.
How can I get the response ?
You can add your output by using the SampleResult object:
String output = "...";
SampleResult.setResponseData( output );
SampleResult.setDataType( org.apache.jmeter.samplers.SampleResult.TEXT );
return
keyword Minimal working code is below, adjust as per your needs:
import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; import org.apache.commons.io.IOUtils; URL url = new URL("http://example.com"); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setRequestMethod("GET"); String response = IOUtils.toString(con.getInputStream(), StandardCharsets.UTF_8); return response;
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.