JMeter HTTP 请求:总是发送 GET 方法

Nat*_*dle 3 jmeter

所有,我向测试 REST 服务发出的每个 HTTP 请求都使用设置为 GET 的方法发送。Tomcat 以 405 - Unsupported Method 拒绝。我将其更改为(POST、PUT 等)无关紧要,Jmeter 总是发送 GET。

我通过创建一个带有 HTTP 请求采样器和查看结果树的线程组来设置最简单的测试用例。我将一个 JSON 正文发送到 REST 服务,该服务仅将请求与 ID 一起回显。与 Google 的 REST 客户端 UI 配合使用非常好。

这是查看结果树的结果:

Response code: 405
Response message: Method Not Allowed

Response headers:
HTTP/1.1 405 Method Not Allowed
Server: Apache-Coyote/1.1
Allow: POST
Content-Type: text/html;charset=utf-8
Content-Language: en
Content-Length: 1045
Date: Fri, 18 Jul 2014 21:39:27 GMT
Run Code Online (Sandbox Code Playgroud)

这是来自我的 REST 服务的 RequestMapping

@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
Run Code Online (Sandbox Code Playgroud)

这是我的结果的一些屏幕截图。我想知道为什么树中的 HTTP 请求下面有两个 URI?请注意 POST 请求看起来是正确的。 获取请求

POST 请求

测试计划 标题管理器

小智 5

由于尚未提供正确答案:在某些情况下导致这种行为的是“跟随重定向”选项。见http://www.sqaforums.com/showflat.php?Cat=0&Number=687068&Main=675937


vin*_*ins 0

Content-Type 应该是 application/json。它不能是文本/html。

在 HTTP 标头管理器中进行设置。我假设您已正确设置身份验证详细信息。