gpt4 book ai didi

wcf - 抛出故障代码 ("Receiver")但以 "Server"响应

转载 作者:行者123 更新时间:2023-12-04 06:14:39 24 4
gpt4 key购买 nike

我正在抛出接收器的故障代码,但客户端正在返回“s:服务器”作为响应故障代码。 我怎样才能得到“s:Receiver”的响应?

我的代码:

throw new FaultException<System.ApplicationException>(new System.ApplicationException("My application broke"), new FaultReason("because i said so"), new FaultCode("Receiver"));

回复:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode>s:Server</faultcode>
<faultstring xml:lang="en-US">because i said so</faultstring>
<detail>
<ApplicationException xmlns="http://schemas.datacontract.org/2004/07/System" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema">
...
</ApplicationException>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>

最佳答案

试试这个:

throw new FaultException<System.ApplicationException>(
new System.ApplicationException("My application broke"),
new FaultReason("because i said so"),
new FaultCode("Receiver", "http://schemas.microsoft.com/ws/2005/05/envelope/none"));

查看接受的答案 .NET WCF faults generating incorrect SOAP 1.1 faultcode values

编辑: http://schemas.xmlsoap.org/soap/envelope/您发布的错误消息中的命名空间表明您正在使用基于 SOAP 1.1 的绑定(bind)。 SOAP 1.1 仅支持以下故障码:VersionMismatch、MustUnderstand、Client 和 Server。 SOAP 1.2 支持:VersionMismatch、MustUnderstand、DataEncodingUnknown、Sender 和 Receiver。无法指定 Sender 故障码的原因可能是绑定(bind)造成的。请尝试指定客户端故障代码。我从 http://msdn.microsoft.com/en-us/library/system.servicemodel.faultcode.aspx 获得故障代码列表.请参阅备注部分。

关于wcf - 抛出故障代码 ("Receiver")但以 "Server"响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7420742/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com