Aracılığıyla paylaş


SoapUnknownHeader.Element Özellik

Tanım

SOAP isteği veya yanıtı için XML Üst Bilgisi öğesini alır veya ayarlar.

public:
 property System::Xml::XmlElement ^ Element { System::Xml::XmlElement ^ get(); void set(System::Xml::XmlElement ^ value); };
public System.Xml.XmlElement Element { get; set; }
member this.Element : System.Xml.XmlElement with get, set
Public Property Element As XmlElement

Özellik Değeri

XmlElement

XmlElement SOAP üst bilgisinin ham XML'ini temsil eden.

Örnekler

Aşağıdaki MyWebService XML Web hizmeti, bildiği SOAP üst bilgisi dışındakiler MyHeader de dahil olmak üzere tüm SOAP üst bilgilerini alır. MyWebMethod XML Web hizmeti yöntemi, istemciye dize olarak geçirilen son bilinmeyen SOAP üst bilgisinin XML özniteliklerini döndürür.

<%@ WebService Language="C#" Class="MyWebService"%>
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml;
using System;

// Define a SOAP header by deriving from the SoapHeader base class.

public class MyHeader : SoapHeader {
    public string MyValue;
}

public class MyWebService {

    public MyHeader myHeader;
    // Receive all SOAP headers besides the MyHeader SOAP header.
    public SoapUnknownHeader[] unknownHeaders;
 
    [WebMethod]
    [SoapHeader("myHeader", Direction=SoapHeaderDirection.InOut)]

    //Receive any SOAP headers other than MyHeader.
    [SoapHeader("unknownHeaders")]

    public string MyWebMethod() {

    string unknownHeaderAttributes = String.Empty;

        // Set myHeader.MyValue to some value.
         
       foreach (SoapUnknownHeader header in unknownHeaders) {
           // Perform some processing on the header.
           foreach (XmlAttribute attribute in header.Element.Attributes) {
              unknownHeaderAttributes = unknownHeaderAttributes + attribute.Name + ":" + attribute.Value + ";";            
           }
           // For those headers that cannot be 
           // processed, set the DidUnderstand property to false.
           header.DidUnderstand = false;
       }
       return unknownHeaderAttributes;
    }
}
<%@ WebService Language="VB" Class="MyWebService"%>
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml
Imports System

' Define a SOAP header by deriving from the SoapHeader base class.
Public Class MyHeader
    Inherits SoapHeader
    Public MyValue As String
End Class

Public Class MyWebService
    
    Public myHeader As MyHeader
    
    ' Receive all SOAP headers besides the MyHeader SOAP header.
    Public unknownHeaders() As SoapUnknownHeader    

    'Receive any SOAP headers other than MyHeader.
    <WebMethod, _
    SoapHeader("myHeader", Direction := SoapHeaderDirection.InOut), _
    SoapHeader("unknownHeaders")> _
    Public Function MyWebMethod() As String
        Dim unknownHeaderAttributes As String = String.Empty
        
        ' Set myHeader.MyValue to some value.
        Dim header As SoapUnknownHeader
        For Each header In  unknownHeaders
            ' Perform some processing on the header.
            Dim attribute As XmlAttribute
            For Each attribute In header.Element.Attributes
                unknownHeaderAttributes &= attribute.Name & ":" & _
                    attribute.Value & ";"
            Next attribute
            ' For those headers that cannot be 
            ' processed, set the DidUnderstand property to false.
            header.DidUnderstand = False
        Next header
        
        Return unknownHeaderAttributes
        
    End Function
End Class

Açıklamalar

XML Web hizmeti yöntemi, XML Web hizmetinin yazılması sırasında bilmediği SOAP üst bilgilerini işlemek isterse, SOAP üst bilgisinin ham XML'sini temsil eden bir XmlElement sınıfı işleyebilir.

Şunlara uygulanır

Ayrıca bkz.