0

强文本 我有一个基本的 Web 服务 (asmx),它会引发肥皂异常。下面是 service.asmx 和 web.config 的代码。我期待来自 IE 中以下格式的 Web 服务的响应。但我在 IE 中得到了单行作为“这是例外”的响应。请您帮我获取下面给出的格式。我无法理解在哪里更改?在任何 web.config 文件或 asmx 中?

service.aspx
============  
<%@ WebService Language="C#" Class="zzz" %>

using System.Web.Services;

using System.Web.Services.Protocols;

using System.Xml;

[WebServiceBinding()]

public class zzz : WebService

{

[WebMethod()]

public void abc() 

{

throw new SoapException("this is the exception", SoapException.ClientFaultCode);

}

}

expecting the response as below
===============================
  <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
  <soap:Fault>
     <faultcode>soap:Client</faultcode>
     <faultstring>Validation Exception</faultstring>
     <detail>
        <ErrorCode>TESTCODE</ErrorCode>
        <ErrorDescription>No matching emp information. Please change your request.</ErrorDescription>
     </detail>
  </soap:Fault>

web.xml
===============================
  <?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<!-- 
Set compilation debug="true" to insert debugging 
symbols into the compiled page. Because this 
affects performance, set this value to true only 
during development.
-->
<compilation debug="true"/>
<!--
The <authentication> section enables configuration 
of the security authentication mode used by 
ASP.NET to identify an incoming user. 
-->
<authentication mode="Windows"/>

<customErrors mode="On"/>

<!--
The <customErrors> section enables configuration 
of what to do if/when an unhandled error occurs 
during the execution of a request. Specifically, 
it enables developers to configure html error pages 
to be displayed in place of a error stack trace.

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
</configuration>
4

1 回答 1

0

我认为问题可能出在 IE 设置中,特别是“显示友好的 http 错误消息”选项。

检查 Fiddler 的原始 http 输出。

于 2012-07-10T21:52:14.210 回答