抛出故障代码(“接收器”)但以“服务器”响应
我抛出了接收器的故障代码,但客户端返回“s:Server”作为响应故障代码。 我如何获得“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>
I'm throwing a FaultCode of Receiver, but the client is getting back "s:Server" as a response faultcode. How can i get a response of "s:Receiver"?
My code:
throw new FaultException<System.ApplicationException>(new System.ApplicationException("My application broke"), new FaultReason("because i said so"), new FaultCode("Receiver"));
response:
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
查看 .NET WCF 故障生成的接受答案不正确的 SOAP 1.1 错误代码值
编辑:您发布的错误消息中的
http://schemas.xmlsoap.org/soap/envelope/
命名空间表明您使用基于 SOAP 1.1 的绑定。 SOAP 1.1 仅支持以下错误代码:VersionMismatch、MustUnderstand、Client 和 Server。 SOAP 1.2 支持:VersionMismatch、MustUnderstand、DataEncodingUnknown、Sender 和 Receiver。您无法指定发件人故障代码的原因可能是由于绑定所致。请尝试指定客户端故障代码。我从 http://msdn.microsoft 获取了故障代码列表.com/en-us/library/system.servicemodel.faultcode.aspx。请参阅备注部分。Try this:
See accepted answer to .NET WCF faults generating incorrect SOAP 1.1 faultcode values
EDIT: The
http://schemas.xmlsoap.org/soap/envelope/
namespace in the fault message you posted indicates that you are using a binding based on SOAP 1.1. SOAP 1.1 only supports the following fault codes: VersionMismatch, MustUnderstand, Client, and Server. SOAP 1.2 supports: VersionMismatch, MustUnderstand, DataEncodingUnknown, Sender, and Receiver. The reason you are unable to specify the Sender fault code may be due to the binding. Try specifying the Client fault code instead. I got the fault code lists from http://msdn.microsoft.com/en-us/library/system.servicemodel.faultcode.aspx. See the Remarks section.