繁体   English   中英

.NET Web服务-SOAP错误

[英].NET Web Services - SOAP Faults

如何在我的C#Web服务中将任何未捕获的异常作为SOAP错误返回? 看来IIS正在“捕获”异常并在默认错误上显示它。 下面是上划线的web.config。

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
  </configSections>
  <system.web>
    <httpRuntime enableVersionHeader="false" />
    <sessionState mode="Off" />
    <compilation defaultLanguage="c#" debug="true" />
    <authentication mode="None" />
        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
    <webServices>
      <protocols>
        <remove name="HttpPost"/>
        <remove name="HttpGet"/>
        <remove name="Documentation"/>
        <remove name="HttpSoap12" />
      </protocols>
    </webServices>
  </system.web>
</configuration>

我相信此链接描述了您要查找的内容:

http://aspalliance.com/727_CodeSnip_Handling_SOAP_Exceptions_in_Web_Services

尝试从配置中删除customErrors部分。

事实证明,导致此问题的HttpModule的Application_EndRequest方法中存在代码问题。

事实证明HttpModule中的某些错误逻辑导致应用程序出错。 解决此问题后,应用程序将按预期运行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM