【发布时间】:2011-10-25 21:46:27
【问题描述】:
我的 ASP.NET 3.5 Web 服务 (asmx) 没有将异常作为 SOAP 错误抛出。我所看到的一切都说这是默认行为,但我的是将所有异常信息作为文本/纯文本发送。这是一个添加了一项服务的新 Web 应用程序项目。开箱即用的行为没有其他变化。如何获取 SOAP 错误?
代码:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class WebService : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
int test1 = 0;
int test2 = 5 / test1;
return "Hello World";
}
}
结果:
HTTP/1.1 500 Internal Server Error
Server: ASP.NET Development Server/10.0.0.0
Date: Tue, 25 Oct 2011 21:39:23 GMT
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/plain; charset=utf-8
Content-Length: 201
Connection: Close
System.DivideByZeroException: Attempted to divide by zero.
at WebApplication.WebService.HelloWorld() in C:\....cs:line 23
【问题讨论】:
标签: asp.net web-services soap