SoapException.Detail Propiedad

Definición

Obtiene un objeto XmlNode que representa la información detallada sobre el error, específica de la aplicación.

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

Valor de propiedad

Información de error específica de la aplicación.

Ejemplos

En el ejemplo siguiente se produce un SoapException, donde el método de servicio web XML establece la Detail propiedad .

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

Comentarios

La Detail propiedad se puede establecer mediante uno de los constructores de clase que acepta un Detail valor.

La Detail propiedad se usa para proporcionar detalles de error específicos de la aplicación relacionados con el Body elemento de la solicitud SOAP. Según la especificación SOAP, si se produce un error porque no se puede procesar la solicitud de cliente debido al Body elemento de la solicitud SOAP, se debe establecer la Detail propiedad . Si se produce un error en las entradas de encabezado de la solicitud SOAP, debe producir un SoapHeaderException, de modo que los detalles del error se devuelvan en el encabezado SOAP. Si no se produce el error, debido al procesamiento del Body elemento , no se debe establecer la Detail propiedad .

Al crear un XmlNode para la Detail propiedad , las Name propiedades y Namespace de DetailElementName se pueden usar para garantizar la coherencia con la especificación SOAP.

Todos los elementos secundarios inmediatos del elemento detail se denominan entradas de detalle y cada entrada de detalle se codifica como un elemento independiente dentro del elemento de detalle.

Se aplica a

Consulte también