Java Web 服务:空数组
从 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这已经在 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.