强文 我有一个基本的Web服务(asmx),它会抛出soap异常。下面是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>
答案 0 :(得分:0)
我认为该问题可以在IE设置中,特别是“显示友好的http错误消息”选项。
用Fiddler检查原始http输出。