Q

How can I call an exception class in XML for my Web service?

I have created a Web service that calls a Standalone Class. I want to know the best feasible way to call an exception class and return the error in XML if an error occurs, but otherwise to send back a class of objects in XML?
In ASP.NET Web services, there's no need for such a distinction. Simply return what you have to return, and it will be sent as part of an XML SOAP message. If an error occurs, just rethrow the exception (or directly don't catch it at all, and the same SOAP message will now contain an exception result (XML, obviously) instead. On the client side, most toolkits (other than .NET, I mean), will translate such a response into a an exception again. .NET proxies will allow you to catch a SoapException in these cases, so you have a familiar programming model always: try..execute..catch. That's all. Of course, as Web services are about XML and SOAP, that's what is going to travel through the wire ALWAYS. No objects there, they're generated by the proxies (client-side) and ASP.NET (server-side).
This was first published in September 2003

Dig deeper on .NET Framework development with XML and XAML

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close