你能从JAX-WS @WebMethod返回一个数组吗? [英] Can you return an array from a JAX-WS @WebMethod?

查看:148
本文介绍了你能从JAX-WS @WebMethod返回一个数组吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很确定你可以,但除了回答标题中的问题之外,你能否解释一下这些问题的优点,缺点,警告(如果有的话)?我知道你不能从WebMethod(这是愚蠢的,IMO,但我不知道设计原因是什么,我应该拒绝判断)返回List,Set,Collection,Map或任何接口。

I'm pretty sure you can, but in addition to answering the question in the title, could you also explain the pros, cons, caveats, if any, to doing so? I know that you can't return a List, Set, Collection, Map, or any interface, from a WebMethod (which is stupid, IMO, but I don't know what the design reasons were should I should probably withhold judgment).

感谢您的任何建议。

-
LES

-- LES

推荐答案

你可以返回数组,我发现它们很有用。

You can return arrays, and I have found them useful.

收集的主要原因是问题是某些语言(例如C)不理解集合的概念,因此,为了保持可移植性,您需要确保传递可以用大多数语言表示的结构。

The main reason that collections are a problem is that some languages, such as C, doesn't understand the concept of a collection, so, to remain portable you need to make certain to pass structures that can be represented in the majority of languages.

此外,我从不擅长传递集合,因为来自Web服务的内容应该是相当静态的。如果要添加它,则将数组转换为集合,然后将数组传递回Web服务以进行更改。

Besides,I am never a fan of passing collections, as, what comes from the webservice should be fairly static. If you want to add to it, then convert the array to a collection, then pass back an array to the webservice to make changes.

这篇关于你能从JAX-WS @WebMethod返回一个数组吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆