开发者

Returning a user friendly error message to client, from a web service

I need to return an error message to the client, if they have entered invalid data when calling m开发者_如何学Cy web service. So if my code is:

    If Not IsNumeric(strOrderID) Then
    Throw New SoapException("Invalid Order ID", SoapException.ClientFaultCode)
End If

I get a web page saying:

System.Web.Services.Protocols.SoapException: Invalid Order ID at Service.GetHeaderValues(String strOrderID)

Is there a way to display a more user friendly error message (such as a message box or just the words "Invalid Order ID")?


My syntax might be off a bit, but you can use something like

return <err>ex.message</err>


You'll need to catch the exception at the client and handle it appropriately (display message, log it, whatever).

The WebService would/could never "show" anything to the user itself.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜