SoapException Constructor
Initializes a new instance of the SoapException class.
Overload List
Initializes a new instance of the SoapException class with the specified exception message and exception code.
Supported by the .NET Compact Framework.
[Visual Basic] Public Sub New(String, XmlQualifiedName)
[C#] public SoapException(string, XmlQualifiedName);
[C++] public: SoapException(String*, XmlQualifiedName*);
[JScript] public function SoapException(String, XmlQualifiedName);
Initializes a new instance of the SoapException class with the specified exception message, exception code and reference to the root cause of the exception.
[Visual Basic] Public Sub New(String, XmlQualifiedName, Exception)
[C#] public SoapException(string, XmlQualifiedName, Exception);
[C++] public: SoapException(String*, XmlQualifiedName*, Exception*);
[JScript] public function SoapException(String, XmlQualifiedName, Exception);
Initializes a new instance of the SoapException class with the specified exception message, exception code and URI identifying the piece of code that caused the exception.
Supported by the .NET Compact Framework.
[Visual Basic] Public Sub New(String, XmlQualifiedName, String)
[C#] public SoapException(string, XmlQualifiedName, string);
[C++] public: SoapException(String*, XmlQualifiedName*, String*);
[JScript] public function SoapException(String, XmlQualifiedName, String);
Initializes a new instance of the SoapException class with the specified exception message, exception code, URI identifying the code that casued the exception and reference to the root cause of the exception.
[Visual Basic] Public Sub New(String, XmlQualifiedName, String, Exception)
[C#] public SoapException(string, XmlQualifiedName, string, Exception);
[C++] public: SoapException(String*, XmlQualifiedName*, String*, Exception*);
[JScript] public function SoapException(String, XmlQualifiedName, String, Exception);
Initializes a new instance of the SoapException class with the specified exception message, exception code, URI identifying the piece of code that caused the exception and application specific exception information.
Supported by the .NET Compact Framework.
[Visual Basic] Public Sub New(String, XmlQualifiedName, String, XmlNode)
[C#] public SoapException(string, XmlQualifiedName, string, XmlNode);
[C++] public: SoapException(String*, XmlQualifiedName*, String*, XmlNode*);
[JScript] public function SoapException(String, XmlQualifiedName, String, XmlNode);
Initializes a new instance of the SoapException class with the specified exception message, exception code, URI identifying the piece of code that caused the exception, application specific exception information and reference to the root cause of the exception.
[Visual Basic] Public Sub New(String, XmlQualifiedName, String, XmlNode, Exception)
[C#] public SoapException(string, XmlQualifiedName, string, XmlNode, Exception);
[C++] public: SoapException(String*, XmlQualifiedName*, String*, XmlNode*, Exception*);
[JScript] public function SoapException(String, XmlQualifiedName, String, XmlNode, Exception);
Example
[Visual Basic, C#] Note This example shows how to use one of the overloaded versions of the SoapException constructor. For other examples that might be available, see the individual overload topics.
[Visual Basic] <%@ WebService Language="VB" class="ThrowSoapException"%> Imports System Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.Xml.Serialization Imports System.Xml Public Class ThrowSoapException Inherits WebService ' This XML Web service method generates a SOAP client fault code. <WebMethod()> _ Public Sub myThrow() ' Build the detail element of the SOAP fault. Dim doc As New System.Xml.XmlDocument() Dim node As System.Xml.XmlNode = doc.CreateNode(XmlNodeType.Element, _ SoapException.DetailElementName.Name, _ SoapException.DetailElementName.Namespace) ' Build specific details for the SoapException. ' Add first child of detail XML element. Dim details As System.Xml.XmlNode = doc.CreateNode(XmlNodeType.Element, _ "mySpecialInfo1", "http://tempuri.org/") ' Add second child of detail XML element with an attribute. Dim details2 As System.Xml.XmlNode = doc.CreateNode(XmlNodeType.Element, _ "mySpecialInfo2", "http://tempuri.org/") Dim attr As XmlAttribute = doc.CreateAttribute("t", "attrName", _ "http://tempuri.org/") attr.Value = "attrValue" details2.Attributes.Append(attr) ' Append the two child elements to the detail node. node.AppendChild(details) node.AppendChild(details2) ' Throw the exception. Dim se As New SoapException("Fault occurred", SoapException.ClientFaultCode, _ Context.Request.Url.AbsoluteUri, node) Throw se Return End Sub End Class [C#] <%@ WebService Language="C#" class="ThrowSoapException"%> using System; using System.Web.Services; using System.Web.Services.Protocols; using System.Xml.Serialization; using System.Xml; public class ThrowSoapException : WebService { // This XML Web service method generates a SOAP client fault code. [WebMethod] public void myThrow(){ // Build the detail element of the SOAP fault. System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); System.Xml.XmlNode node = doc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace); // Build specific details for the SoapException. // Add first child of detail XML element. System.Xml.XmlNode details = doc.CreateNode(XmlNodeType.Element, "mySpecialInfo1", "http://tempuri.org/"); System.Xml.XmlNode detailsChild = doc.CreateNode(XmlNodeType.Element, "childOfSpecialInfo", "http://tempuri.org/"); details.AppendChild(detailsChild); // Add second child of detail XML element with an attribute. System.Xml.XmlNode details2 = doc.CreateNode(XmlNodeType.Element, "mySpecialInfo2", "http://tempuri.org/"); XmlAttribute attr = doc.CreateAttribute("t", "attrName", "http://tempuri.org/"); attr.Value = "attrValue"; details2.Attributes.Append(attr); // Append the two child elements to the detail node. node.AppendChild(details); node.AppendChild(details2); //Throw the exception. SoapException se = new SoapException("Fault occurred", SoapException.ClientFaultCode,Context.Request.Url.AbsoluteUri,node); throw se; return; } }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
See Also
SoapException Class | SoapException Members | System.Web.Services.Protocols Namespace