다음을 통해 공유


SoapUnknownHeader.Element 속성

정의

SOAP 요청 또는 응답에 대한 XML 헤더 요소를 가져오거나 설정합니다.

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

속성 값

XmlElement

SOAP 헤더의 원시 XML을 나타내는 XmlElement입니다.

예제

다음 MyWebService 이외의 비롯 하 여 모든 SOAP 헤더를 수신 하는 XML 웹 서비스는 MyHeader SOAP 헤더를 인식 합니다. MyWebMethod XML 웹 서비스 메서드에 문자열로 전달 된 마지막 알 수 없는 SOAP 헤더의 XML 특성을 클라이언트에 반환 합니다.

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

설명

경우는 XML 웹 서비스 메서드를 알지 못합니다에 대 한 XML 웹 서비스는 작성 당시 SOAP 헤더를 처리 하려는 것을 처리할 수는 XmlElement SOAP 헤더의 원시 XML을 나타내는 클래스입니다.

적용 대상

추가 정보