1

我正在使用一个 REST Web 服务,它公开了一个类似的方法

    public boolean uploadConfig(String configContent);

在我的客户端中,我以这种方式注释了这个接口:

    public boolean uploadConfig(@WebParam(name = "configContent") String configContent);

所以'configContent'参数应该是一个Body参数。

问题是,如果我传递一个 null configContent,则从 ClientProxyImpl.invoke() 方法抛出 NullPointerException。

我当然可以在我的代码中检查输入参数的空值,但我想知道如何使用 CXF 客户端库本地管理此检查。也许界面中缺少一些注释?

非常感谢!

最好的

盖尔西

4

1 回答 1

1

@WebParam 注释仅适用于 JAX-WS。

假设您尝试以 HTML 表单帖子的形式发送数据,您应该使用 JAX-RS @FormParam注释参数。

public boolean uploadConfig(@FormParam("configContent") String configContent);

空值将导致没有参数随请求一起发送。

于 2013-10-25T16:30:50.340 回答