Ask the Expert

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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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: