Java Web 服务:空数组

发布于 2024-09-19 20:56:09 字数 335 浏览 3 评论 0原文

从 Java 中的 Web 服务返回空数组的正确方法是什么?我需要客户端上的空数组不应该为空。如果我使用带有默认数据绑定的 Apache CXF 或 Axis 2,我会收到空​​数组的 null 值。 如果我使用 CXF 和 AegisDatabinding——问题就解决了,但是当我从 Axis 2 客户端调用此 Web 服务时——我在服务器上收到空参数(就像这个问题通过 CXF 的 Web 服务调用提供空参数)。

谢谢。

What is the right way to return empty arrays from webservices in Java? I need that empty arrays sholdn't be nulls on client. If I use Apache CXF or Axis 2 with default databinding I receive null insted of empty arrays.
If I use CXF and AegisDatabinding -- problem is solved, but when I calling this webservice from Axis 2 client -- I receive null parameters on server (like in this question Web Service Call Via CXF Gives Null Parameters).

Thanks.

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

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

发布评论

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

评论(1

生寂 2024-09-26 20:56:09

这已经在 CXF 列表和 JIRA 上讨论过几次:

http://cxf.547215.n5.nabble.com/CXF-2627-still-failign-in-2-2-9-td1247184.html#a1247184

https://issues.apache.org/jira/browse/CXF-2978

https://issues.apache.org/jira/browse/CXF-2627< /a>

唯一的方法是编写添加 @XmlElementWrapper 注释的自定义包装器对象。

This has been discussed a couple times on the CXF lists and JIRA:

http://cxf.547215.n5.nabble.com/CXF-2627-still-failign-in-2-2-9-td1247184.html#a1247184

https://issues.apache.org/jira/browse/CXF-2978

https://issues.apache.org/jira/browse/CXF-2627

The only way is to write custom wrapper objects that add the @XmlElementWrapper annotation.

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