Welcome   |  ASP.NET   |  Web Services   |  How Do I...?   |  Class Browser  | WPF Quick Starts
  |   I want my samples in...   

ASP.NET Web Services QuickStart Tutorial

Go To...

ASP.NET Web Service That Throws a Soap Exception with Custom Information

The server can send custom fault information to the client using a SoapException. When a SoapException is thrown (and not caught) the server sends the error information on the wire in the form of a SOAP fault. The SOAP fault is deserialized back into a SoapException at the client. Custom (machine-readable) error information is sent in the Detail element of a SOAP fault. A SOAP fault also includes a human-readable error message, a fault code and optionally a SOAP actor.

		
//assume that there was an error validating the SOAP Message
if(true)
{
    XmlDocument doc = new XmlDocument();
    //insert your own XML into the XmlDocument, 
    //this will go into the Detail element of the SOAP fault
    string errorMsg = "An error was received...";
    //the SOAP fault will contain a human-readable error message, 
    //the fault code, the SOAP actor, and the detail element    
    SoapException exc = new SoapException(errorMsg, SoapException.ClientFaultCode, "", detail);
    throw exc; 
}
C#

Run C# Sample
Run Sample View Source



Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright � 2005 Microsoft Corporation. All rights reserved.


Hosted by MaximumASP | Found a broken link? | Contact Us | Terms and conditions | Privacy Policy | Advertise with us
� 2000 - 2010  Mindcracker LLC. All Rights Reserved