在使用SOAPUI测试REST控制器时,请求中的单个意外空值

发布于 2025-01-28 07:04:29 字数 1044 浏览 1 评论 0原文

我有一个控制器,该控制器通过SOAPUI接收请求对象(下面的屏幕)。让我感到困惑的是,此请求对象的两个属性中只有一个是null(不应该是),另一个是它的本质。

这是我的控制器:

@RestController
public class RestituzioneController {
    private static final Logger logger = LoggerFactory.getLogger(RestituzioneController.class);
    @Autowired
    RestService restService;
    
    @PostMapping(value="/restituzione")
    public RestituzioneResponse restituzione(@RequestBody RestituzioneRequest request) {
        logger.info("Start --------------- ");
        logger.info("request {}",request.toString());

并且请求类是(我正在使用Lombok):

@Data
public class RestituzioneRequest {
    private @NotEmpty String code;
    private @NotEmpty String numP;
}

通过SOAPUI执行帖子呼叫(下面),这就是日志所述:

开始-------------------
请求RestituzionereQuest(代码= null, nump = 12xxx0000123)

soapui参数:

I have a Controller which receives a request object via SoapUI (screen below). What confuses me it is that only one of the 2 attributes of this request object is null (it should not be), the other it is what it is meant to be.

This is my Controller:

@RestController
public class RestituzioneController {
    private static final Logger logger = LoggerFactory.getLogger(RestituzioneController.class);
    @Autowired
    RestService restService;
    
    @PostMapping(value="/restituzione")
    public RestituzioneResponse restituzione(@RequestBody RestituzioneRequest request) {
        logger.info("Start --------------- ");
        logger.info("request {}",request.toString());

and Request class being (I'm using Lombok):

@Data
public class RestituzioneRequest {
    private @NotEmpty String code;
    private @NotEmpty String numP;
}

After executing a POST call through SoapUI (screen below) this is what the log states:

Start ---------------
request RestituzioneRequest(code=null,
numP=12XXX0000123)

SoapUI parameters:
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相权↑美人 2025-02-04 07:04:29

您是否尝试使用其他工具。 Postman
我很确定您的代码很好,这可能是SOAPUI版本问题的冲突。

Did you try with other tools eg. Postman
I'm pretty sure your code is perfectly fine, It might be conflict by SoapUI version issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文