无法使用 Jmeter 成功调用休息服务(方法:DELETE)

Cannot make successful call using Jmeter to a rest service (Method: DELETE)

我写了一个 REST 网络服务。它接受 RequestMethod.DELETE,消耗 "application/json"。我已经在本地使用 chrome 的 DHC 客户端对此进行了测试。它是成功的。但是当我使用 Jmeter 测试它时,响应是:"The request sent by the client was syntactically incorrect"。我的观点是它如何与 dhc 客户端一起工作,为什么不在 Jmeter 中?

Java部分:

@RequestMapping(value = { "/{apiVersion}/provision"}, 
        method = RequestMethod.DELETE, consumes = "application/json")
public @ResponseBody
EspCancelResponse cancel(@RequestBody EspCancelRequest cancelRequest) throws ProvisionException{
//do something
}

ESPCancelRequest:

@JsonPropertyOrder({"espCentralTransactionId"})
public class EspCancelRequest {

private String espCentralTransactionId;

public String getEspCentralTransactionId() {
    return espCentralTransactionId;
}

@JsonProperty("espCentralTransactionId")
public void setEspCentralTransactionId(String espCentralTransactionId) {
    this.espCentralTransactionId = espCentralTransactionId;
   }
}

来自您的 Java 部分:

method = RequestMethod.DELETE, consumes = "application/json")

这可能是因为您的服务器将您的请求正文视为纯文本。

尝试添加 HTTP Header Manager to send Content-Type header with the value of application/json

另一个原因可能是您的应用程序服务器 ignoring your message body. Although DELETE methods are allowed to have the body 它可能被服务器丢弃,您的应用程序继续存在。

我猜这是 Jmeter 中的一个错误。当方法为 DELETE 时,它无法发送正文。看到这个 post 后,我得出了这样的理解: https://bz.apache.org/bugzilla/show_bug.cgi?id=55255

:(。考虑使用其他工具或最新版本。