strong text 我有一個基本的web服務(asmx)拋出了soap異常。以下是service.asmx和web.config的代碼。我期待在IE中以下格式的Web服務響應。但我在IE中獲得了單行的響應,因爲「這是例外」。請你幫我獲取下面給出的格式。我無法理解在哪裏更改?在任何web.config文件或asmx中?來自asmx web服務的故障消息格式
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>
附上你在IE中看到的請 – 2012-07-10 21:51:08
托馬斯,我在IE下面得到消息。它唯一的一行「這是例外」。但我需要在我的問題的格式 – user1515989 2012-07-11 01:41:22
答案在這裏https://msdn.microsoft.com/en-us/en-en/library/aa480514.aspx – fubo 2015-01-30 09:47:18