SoapException.Detail プロパティ

定義

アプリケーション固有のエラー情報を表す XmlNode を取得します。Gets an XmlNode that represents the application-specific error information details.

public:
 property System::Xml::XmlNode ^ Detail { System::Xml::XmlNode ^ get(); };
public System.Xml.XmlNode Detail { get; }
member this.Detail : System.Xml.XmlNode
Public ReadOnly Property Detail As XmlNode

プロパティ値

XmlNode

アプリケーション固有のエラー情報。The application-specific error information.

次の例では、XML Web サービスメソッドが Detail プロパティを設定する SoapExceptionをスローします。The following example throws a SoapException, where the XML Web service method sets the Detail property.

<%@ 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;    
    }
}
<%@ 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

注釈

Detail プロパティは、Detail 値を受け取るクラスコンストラクターのいずれかを使用して設定できます。The Detail property can be set using one of the class constructors that accepts a Detail value.

Detail プロパティは、SOAP 要求の Body 要素に関連するアプリケーション固有のエラーの詳細を指定するために使用されます。The Detail property is used to supply application-specific error details related to the Body element of the SOAP request. Soap 仕様によれば、SOAP 要求の Body 要素によってクライアント要求を処理できないことが原因でエラーが発生した場合は、Detail プロパティを設定する必要があります。According to the SOAP specification, if an error occurs because the client request cannot be processed due to the Body element of the SOAP request, the Detail property must be set. SOAP 要求のヘッダーエントリでエラーが発生した場合は、エラーの詳細が SOAP ヘッダーで返されるように、SoapHeaderExceptionをスローする必要があります。If an error occurs in the header entries of the SOAP request, you must throw a SoapHeaderException, so that the error details are returned in the SOAP header. Body 要素の処理によってエラーが発生しない場合は、Detail プロパティを設定しないようにする必要があります。If the error does not occur, due to the processing of the Body element, then the Detail property must not be set.

Detail プロパティの XmlNode を構築する場合、DetailElementNameName および Namespace プロパティを使用して、SOAP 仕様との一貫性を確保できます。In building an XmlNode for the Detail property, the Name and Namespace properties of DetailElementName can be used to ensure consistency with the SOAP specification.

Detail 要素のすべての直接の子要素は詳細エントリと呼ばれ、各詳細エントリは詳細要素内の独立した要素としてエンコードされます。All immediate child elements of the detail element are called detail entries and each detail entry is encoded as an independent element within the detail element.

適用対象

こちらもご覧ください