How To Return Error Messages From A Web Service
Contents |
ASP.NET Community Standup Forums Help Home/ASP.NET Forums/Advanced ASP.NET/WCF, ASMX and other Web Services/Returning a error message from within a .NET web service in
Exception Handling In Web Services In Java
C# Returning a error message from within a .NET web service exception handling in web services c# in C# RSS 2 replies Last post Oct 09, 2007 01:47 AM by zhangming870 ‹ Previous Thread|Next Thread web service exception handling best practices › Print Share Twitter Facebook Email Shortcuts Active Threads Unanswered Threads Unresolved Threads Support Options Advanced Search Reply thuhue Contributor 2109 Points 2980 Posts Returning a error message
Exception Handling In Restful Web Services
from within a .NET web service in C# Oct 05, 2007 03:07 AM|thuhue|LINK Please advise sample code for returning a error message from within a .NET web service in C#? . Thanks. Please mark this post as "Answer" and earn a point. Reply skurocks Participant 800 Points 214 Posts Re: Returning a error message from within a .NET
Web Service Exception Handling Best Practices Java
web service in C# Oct 05, 2007 03:38 AM|skurocks|LINK refer the below article http://msdn.microsoft.com/en-us/library/ds492xtk(VS.71).aspx Thanks Sku Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread. Reply zhangming870 Member 190 Points 40 Posts Re: Returning a error message from within a .NET web service in C# Oct 09, 2007 01:47 AM|zhangming870|LINK Hi thuhue, You can throw a SoapException in your webservice and add some information in it and catch the exception in your client . Here is my codes below, hope it is helpful to you. [WebMethod] public string HelloWorld() { string myNS = "Microsoft.Samples.XmlMessaging.WebServices.SoapExceptionSample"; XmlDocument doc = new XmlDocument(); XmlNode detail = doc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace); XmlNode errorType = doc.CreateNode(XmlNodeType.Element,"ErrorType",myNS); errorType.InnerText = "Validation"; XmlNode lineNum = doc.CreateNode(XmlNodeType.Element,"Line",myNS); lineNum.InnerText = "24"; detail.AppendChild(errorType); detail.AppendChild(lineNum); string errorMsg = "this is errorMsg"; SoapException exc = new SoapException(errorMsg, SoapException.ClientFaultCode, "", detail); throw exc; return "Hello World"; } private void button1_Click(object sender, EventArgs e) { localhost.Service1 ser = new WindowsApplication1.localhost.Service1(); try { stri
here for a quick overview of the site Help Center Detailed answers to any questions you might have soap exception handling c# Meta Discuss the workings and policies of this site About Us
Web Service Exception C#
Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with handling and throwing exceptions in xml web services us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just http://forums.asp.net/t/1166652.aspx?Returning+a+error+message+from+within+a+NET+web+service+in+C+ like you, helping each other. Join them; it only takes a minute: Sign up .NET Web Service - How to return an error? up vote 3 down vote favorite I've been working on some web services lately in c# asp.net (3.5). My method is like so and returns a User object consisting of some basic user-related http://stackoverflow.com/questions/11755585/net-web-service-how-to-return-an-error fields (name, age, i etc).. [WebMethod, SoapHeader("AuthHeader")] public user[] Employees(int count) { user[] myUsers = new user[count];
here for a quick overview of the site Help Center Detailed answers to any questions you might have http://programmers.stackexchange.com/questions/294257/should-a-web-service-return-an-error-message-if-it-receives-unknown-parameters Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Programmers Questions Tags Users Badges Unanswered Ask Question _ Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about web service software development. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Should a web service return an error message if it receives unknown parameters? up vote 4 down vote favorite I have exception handling in a web service which allows to retrieve users: http://example.com/users. It returns a list of users. That service accepts a number of parameters (age, gender) to select which users to retrieve. Examples: http://example.com/users?age=34 http://example.com/users?gender=male Should that service return an error message if the client is passing an unknown parameter? Example: >>> GET http://example.com/users?cylinders=16 <<< 400 Bad Request <<< { 'message' : "Invalid parameter 'cylinders'" } (To me it's clear that a web service should validate the parameters it receives, but the case of unknown parameters is not clear to me) code-quality web-services error-handling share|improve this question asked Aug 21 '15 at 13:04 Silvan Mühlemann 1212 add a comment| 1 Answer 1 active oldest votes up vote 5 down vote Technically, such checking requires an additional step. You have to list all the parameters, and compare this list with the list of allowed ones. Then, if you decide to accept an additional parameter, you have to change this list, requiring even more work. All this