gpt4 book ai didi

WCF类型错误和内部服务器错误代码500?

转载 作者:行者123 更新时间:2023-12-04 18:54:29 25 4
gpt4 key购买 nike

这是我的回复信封:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode>s:Client</faultcode>
<faultstring xml:lang="en-US">The creator of this fault did not specify a Reason.</faultstring>
<detail>
<ServiceFault xmlns="http://schemas.datacontract.org/2004/07/Zagat.Services.FaultException" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<ReasonCollection xmlns:a="http://schemas.datacontract.org/2004/07/Zagat.Enterprise.Domain"/>
<ReasonMessage>Credentials are not valid</ReasonMessage>
</ServiceFault>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
enter code here

这是我的标题:
HTTP/1.1 500 Internal Server Error
Date: Wed, 01 Jul 2009 17:55:33 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Content-Length: 564

我怎样才能让IIS返回200而不是500?我的代码在服务器上运行,我只是将错误发送给客户端进行处理。

丹尼尔

最佳答案

您可以轻松地自定义WCF的错误处理。参见Nicholas Allen的Indigo Blog中的Modifying HTTP Error Codes, Part 1Part 2; Andre de Cavaignac的WCF: Throwing Exceptions With WebHttpBinding;以及Brajendra Singh的Exception Handling in WCF Web Service

关于WCF类型错误和内部服务器错误代码500?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1070621/

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