java webservice 返回数组,如何配置WebService返回ArrayList而不是Array?

作者分享了Java中使用JAX-WS实现的webservice返回泛型List的问题,但在.NET应用中VS生成的是Array。寻求如何在C#调用时得到真正的List或ArrayList,包括C#代码示例和解决方法。
摘要由CSDN通过智能技术生成

I have a web service in java that implemented on jax-ws. This web service return an generic list of User. It's working very good :).

@Stateless(name = "AdminToolSessionEJB")

@RemoteBinding(jndiBinding = "AdminToolSessionRemote")

@Remote(AdminToolSessionRemote.class)

@WebService

public class AdminToolSessionBean implements AdminToolSessionRemote {

...

@WebMethod(operationName = "GetAllUsers")

@WebResult(name = "AllUsers")

public List getAllUsers() {

return userSessionRemote.getAllUsers();

}

...

}

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name = "User")

public class User extends BasicDataTransferObject {

...

@XmlElement(name = "Groups")

private List groups;

...

}

But I will use this web service in .Net Applications. When I add this web service as a wcf service or web service in VS2005 or VS2008 or VS2010, VS generate array instead od generic list 'Group[] Groups'. I change 'Collection Type' in 'Configuration Service Reference ...' dialog to 'System.Collections.Generic.List' but VS generate array :(.

I need to VS generate generic list or ArrayList, what I should to do?

解决方案

I'm not sure how to define this in java. However, in my C# service, my main transaction parameter (a purchase order) contains a list of line items defined like this:

private LineItems LineItemsField;

[DataMember(Order=13, EmitDefaultValue=false)]

public LineItems LineItems {

get { return this.LineItemsField; }

set { this.LineItemsField = value; }

}

LineItems is another C# class, defined like this:

[CollectionDataContract(Namespace="")]

public class LineItems : List

{

}

LineItem is the actual class that contains the line item fields.

The LineItems appears in WSDL as:

ArrayOfLineItem is defined as:

And of course, the LineItem class itself is defined elsewhere. Hopefully that helps.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值