我遇到了一个问题,试图返回一个对象,该对象包含一个可以容纳一个孙集对象的集合的子对象。我收到一个错误,'主持人强行关闭连接'。WCF中的复杂数据类型?
有什么办法可以使这项工作?我现在有类似这样的结构:
伪代码:
Person:
IEnumerable<Order>
Order:
IEnumerable<OrderLine>
所有这三个对象具有DataContract属性和所有的公共属性我要暴露(包括了IEnumerable的)有数据成员的属性。
我在我的服务上有多个OperationContract,并且所有方法都返回一个对象,或者一个对象的IEnumerable完美地工作。只有当我尝试嵌套IEnumerable它变成坏。同样在我的客户服务参考中,我选择了通用列表作为我的集合类型。我只想强调,只有我的一个操作/方法失败并出现此错误 - 其余部分完美工作。
EDIT(更详细的错误描述):
[SocketException (0x2746): An existing connection was forcibly closed by
the remote host]
[IOException: Unable to read data from the transport connection:
An existing connection was forcibly closed by the remote host.]
[WebException: The underlying connection was closed: An unexpected
error occurred on a receive.]
[CommunicationException: An error occurred while receiving the HTTP
response to http://myservice.mydomain.dk/MyService.svc. This could
be due to the service endpoint binding not using the HTTP protocol.
This could also be due to an HTTP request context being aborted by
the server (possibly due to the service shutting down). See server
logs for more details.]
我试图寻找日志,但我无法找到任何...还我使用的WSHttpBinding和HTTP端点。
您的对象中是否有不正确的序列化? – 2008-10-15 09:12:07
我不知道。我想也许嵌套的IEnumberable可能无法序列化?但是我怎么知道?我可以一路调试到实际OperationContract的返回,一切都很好,但交通运输似乎出了问题。我没有序列化属性,而是使用[DataMember] –
2008-10-15 09:21:21
我面临着同样的错误,因为我..我的类也定义了枚举属性,但我没有看到这是任何地方的问题..枚举应该没问题..你通过设置默认值是什么意思?他们是价值类型,所以他们总是有一个默认值。我会尝试删除枚举属性,看看是否修复它..这里是支持的数据约定类的一些信息http://msdn.microsoft.com/en-us/library/ms731923.aspx – 2010-10-29 00:17:36