sách gpt4 ai đã đi

wcf - WCF 中的复杂数据类型?

In lại 作者:行者123 更新时间:2023-12-03 11:44:50 26 4
mua khóa gpt4 Nike

我在尝试返回一个包含子对象集合的对象时遇到了问题,该集合又可以包含孙对象的集合。我收到一个错误,“主机强制关闭连接”。

有什么办法可以使这项工作?我目前有一个类似这样的结构:

伪代码:

Person:
IEnumerable

Order:
IEnumerable

所有三个对象都具有 DataContract 属性,并且我想要公开的所有公共(public)属性(包括 IEnumerable 的)都具有 DataMember 属性。

我的服务上有多个 OperationContract,所有返回单个对象或对象的 IEnumerable 的方法都可以正常工作。只有当我尝试嵌套 IEnumerable 时,它才会变坏。同样在我的客户服务引用中,我选择了通用列表作为我的集合类型。我只想强调, 我的操作/方法中只有一个因此错误而失败-其余的都可以正常工作 .

编辑(更详细的错误描述):
[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 端点。

1 Câu trả lời

请注意,您需要了解如何使用 WCF 日志记录实用程序:

Logging info.

Config Editor (使其快速设置)。

Trace viewer.非常棒。允许跟踪多个服务(客户端和服务器)并可以加入它们并帮助您分析所有细节。让您真正快速地找到问题的根源。 (因为当出现服务器 WCF 错误时,客户端不太可能获取有用的数据。)

关于wcf - WCF 中的复杂数据类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/204032/

26 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com