开发者

In .NET web services, how can the SoapException.Message property be easily readable?

I am writing an ASP.NET web service and am throwing a SoapException with a message:

throw new SoapException("BANG!", SoapException.ClientFaultCode);

When I create an ASP.NET client, and request a label to dis开发者_JAVA技巧play the SoapException.Message property, it displays a message similar to the following:

System.Web.Services.Protocols.SoapException: BANG! at WebServiceException.WebService1.HelloWorld() in [DIRECTORY]\WebService1.asmx.cs:line 23

Is there an easy way to simply be presented with the message BANG! rather than this entire string? Or should I just use regular expressions?


If you configure your web service to turn on custom error messages, the stack trace will not be present in the SOAP fault, which in turn will mean your client will not see it.

In web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    ...
    <system.web>
        ...
        <customErrors mode="On"/>
        ...
    </system.web>
    ...
</configuration>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜