SoapException.Detail プロパティ
アセンブリ: System.Web.Services (system.web.services.dll 内)


Detail プロパティは、Detail 値を受け入れるクラス コンストラクタの 1 つを使用して設定できます。
Detail プロパティを使用して、SOAP 要求の Body 要素に関連している、アプリケーション固有のエラー詳細を提供します。SOAP 要求の Body 要素が原因でクライアント要求を処理できないためにエラーが発生した場合は、SOAP 仕様に従い、Detail プロパティを設定する必要があります。SOAP 要求のヘッダー エントリ内でエラーが発生した場合は、SOAP ヘッダーでエラー詳細が返されるように、SoapHeaderException をスローする必要があります。Body 要素の処理が原因となるエラーが発生しなかった場合は、Detail プロパティを設定しないでください。
Detail プロパティの XmlNode を構築するときに、DetailElementName の Name プロパティと Namespace プロパティを使用すると、SOAP 仕様に確実に準拠させることができます。
詳細要素の直下の子要素は、詳細エントリと呼ばれます。各詳細エントリは、詳細要素内の独立した要素としてエンコードされています。

SoapException をスローする例を次に示します。この例では、XML Web サービス メソッドが Detail プロパティを設定します。
<%@ 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
<%@ 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; } }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- SoapException.Detail プロパティのページへのリンク