Click here to Skip to main content
15,884,425 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I wrote a c# Web Service that connects to database, retrieves data into a dataset and returns that dataset to a Stand alone application also written in C#. I can display that data in my application.

My Question is: When the Web service encounters a problem, such as 'unable to get oracle connection' because maybe the database is down...

How do I return the error message from the web service to my application and display it in a Message Box?
Posted
Comments
virang_21 6-Nov-14 17:05pm    
Is it a WCF service or asmx web service ?

For WCF service

http://www.codeproject.com/Articles/294609/Uing-FaultContract-to-throw-custom-error-informati

Silver13 6-Nov-14 17:07pm    
Asmx.
virang_21 6-Nov-14 17:24pm    
There may be a better way to do it but have a look at this article

http://www.developer.com/net/csharp/article.php/3088231/Exception-Handling-in-Web-Services.htm

Sergey Alexandrovich Kryukov 6-Nov-14 17:25pm    
It all depends on your Service Contract. (Do you use WCF Service Contracts at all?) You could designed it to deliver some problem diagnostics for some particular cases.
—SA

1 solution

Quote:
Propagating errors back to a client is done by throwing exceptions. A Web service method can do this in the following ways:
- Throw a SoapException exception.
- Throw a SoapHeaderException exception.
- Throw an exception specific to the problem.
- Allow ASP.NET to throw the exception.


Read the documentation and check which way is most suitable for your requirements.

Handling and Throwing Exceptions in XML Web Services[^]
How to: Throw Exceptions from a Web Service Created Using ASP.NET[^]
How to: Handle Exceptions Thrown by a Web Service Method[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900