我开发了一个休息服务器,我把它放在localhost中运行,我正在尝试使用JMeter执行测试,发送请求post和gets(取决于被调用的方法)。
我已经发送到Rest服务器,并在简单的帖子请求中得到JMeter的结果,获取请求,发送带帖子的文件,并发送带有帖子的Json。
但我不知道如何将Form-UrlEncoded
对象发送到服务器。我的Rest服务器使用application/x-www-form-urlencoded
,我需要发送3个String参数。
有一些方法可以为每个参数设置MimeType
并执行测试吗?
我正在使用Jmeter 2.7
我通过禁用选项解决了这个问题:
use multipart/form-data for post
启用:
redirect automatically
而不是:
follow redirect
我通常在表“使用请求发送参数”中的参数与每个相应的名称。
答案 0 :(得分:10)
要将表单参数作为application / x-www-form-urlencoded发送,请添加一个标题参数Content-Type,其值为application / x-www-form-urlencoded。
以下步骤适用于Jmeter 2.3.4
保留"内容编码:" HTTP请求的文本框为空。
这对于PUT请求不起作用。 对于put请求添加参数作为路径参数并设置Content-Type标头,然后Jmeter将自行完成。
答案 1 :(得分:4)
这是使用jmeter进行x-www-form-urlencoded测试的HTTP POST的解决方案。你只是喜欢这些。
转到线程组 - >添加监听器 - >视图结果表,查看结果树。看到回应的过程。
答案 2 :(得分:2)
您是否尝试使用BadBoy或JMeter Proxy保存测试以查看应用程序实际发送的内容?
要查看幕后发生的情况,如果您使用的是FireFox,则还可以使用FireBug
;如果您使用的是Chrome,则可以使用Ctrl+Shift+i
。
答案 3 :(得分:1)
只有在HTTP标头管理器中为HTTP请求添加所需的内容类型后,才会立即执行IllegalCharsetNameException。
希望这有帮助。
答案 4 :(得分:-1)
按照提到的确切步骤我仍然看到抛出的异常
响应代码:非HTTP响应代码:java.nio.charset.IllegalCharsetNameException 响应消息:非HTTP响应消息:application / x-www-form-urlencoded
java.nio.charset.IllegalCharsetNameException: application/x-www-form-urlencoded
at java.nio.charset.Charset.checkName(Charset.java:315)
at java.nio.charset.Charset.lookup2(Charset.java:484)
at java.nio.charset.Charset.lookup(Charset.java:464)
at java.nio.charset.Charset.forName(Charset.java:528)
at org.apache.http.entity.ContentType.create(ContentType.java:210)
at org.apache.http.entity.StringEntity.<init>(StringEntity.java:116)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sendPostData(HTTPHC4Impl.java:1340)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.handleMethod(HTTPHC4Impl.java:592)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:409)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1166)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1155)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:475)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:418)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:249)
at java.lang.Thread.run(Thread.java:745)