SoapHeaderAttribute 클래스

정의

이 특성은 XML Web services 메서드 또는 XML Web services 클라이언트에서 처리할 수 있는 SOAP 헤더를 지정하기 위해 XML Web services 메서드 또는 XML Web services 클라이언트에 적용됩니다. 이 클래스는 상속될 수 없습니다.

public ref class SoapHeaderAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=true)]
public sealed class SoapHeaderAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=true, Inherited=true)]
public sealed class SoapHeaderAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=true)>]
type SoapHeaderAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=true, Inherited=true)>]
type SoapHeaderAttribute = class
    inherit Attribute
Public NotInheritable Class SoapHeaderAttribute
Inherits Attribute
상속
SoapHeaderAttribute
특성

예제

다음 MyWebService XML 웹 서비스는 형식 MyHeader중 하나를 SoapHeader 정의합니다. Hello XML 웹 서비스 메서드를 사용하려면 클라이언트에서 이 SoapHeader메서드를 사용하여 XML 웹 서비스 메서드를 호출해야 합니다. Hello 또한 XML 웹 서비스는 .을 제외한 MyHeader모든 SOAP 헤더를 catch합니다.

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

// Define a SOAP header by deriving from the SoapHeader base class.
// The header contains just one string value.
public class MyHeader : SoapHeader {
    public string MyValue;
}

public class MyWebService {
    // Member variable to receive the contents of the MyHeader SoapHeader.
    public MyHeader myHeader;

    // Member variable to receive all headers other than MyHeader.
    public SoapUnknownHeader[] unknownHeaders;
 
    [WebMethod]
    [SoapHeader("myHeader", Direction=SoapHeaderDirection.InOut)]

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

       // Process the MyHeader SoapHeader.
       if (myHeader.MyValue == "Some string") {
          // Process the header.
       }
       foreach (SoapHeader header in unknownHeaders) {
           // Perform some processing on header.
           
           // For those headers that cannot be processed,
           // set the DidUnderstand property to false.
           header.DidUnderstand = false;
       }
    }
}
<%@ WebService Language="VB" Class="MyWebService"%>
Imports System.Web.Services
Imports System.Web.Services.Protocols

' Define a SOAP header by deriving from the SoapHeader base class.
' The header contains just one string value.
Public Class MyHeader
    Inherits SoapHeader
    Public MyValue As String
End Class

Public Class MyWebService
    ' Member variable to receive the contents of the MyHeader SoapHeader.
    Public myHeader As MyHeader
    
    ' Member variable to receive all headers other than MyHeader.
    Public unknownHeaders() As SoapUnknownHeader
    
    ' Receive any SOAP headers other than MyHeader.
    <WebMethod, _
        SoapHeader("myHeader", Direction := SoapHeaderDirection.InOut), _
        SoapHeader("unknownHeaders")> _
    Public Sub Hello()        
        
        ' Process the MyHeader SoapHeader.
        If myHeader.MyValue = "Some string" Then
            ' Process the header.
        End If 
        Dim header As SoapHeader
        For Each header In  unknownHeaders
            ' Perform some processing on header
            ' For those headers that cannot be processed, 
            ' set the DidUnderstand to false.
            header.DidUnderstand = False
        Next header
    End Sub
End Class

설명

SOAP 헤더를 받고 처리하는 기본 단계는 다음과 같습니다.

  1. SOAP 헤더에 전달된 데이터를 나타내는 클래스 SoapHeader 를 만듭니다.

  2. 1단계에서 만든 형식의 XML 웹 서비스 클래스 또는 XML 웹 서비스 클라이언트 프록시 클래스에 멤버를 추가합니다.

  3. SoapHeaderAttribute 속성의 2단계에서 만든 멤버를 지정하여 프록시 클래스의 XML 웹 서비스 메서드 또는 해당 메서드에 MemberName 적용합니다.

  4. XML 웹 서비스 메서드 또는 XML 웹 서비스 클라이언트 코드에서 액세스를 MemberName SOAP 헤더에서 전송 되는 데이터를 처리 하는 속성입니다.

자세한 내용은 속성을 참조하세요 MemberName .

생성자

SoapHeaderAttribute(String)

SOAP 헤더 내용을 나타내는 XML Web services 클래스의 멤버를 설정하여 SoapHeaderAttribute 클래스의 새 인스턴스를 초기화합니다.

속성

Direction

해당 SOAP 헤더가 XML Web services를 위한 것인지 아니면 XML Web services 클라이언트를 위한 것인지 아니면 둘 모두를 위한 것인지 여부를 나타내는 값을 가져오거나 설정합니다.

MemberName

SOAP 헤더 내용을 나타내는 XML Web services 클래스의 멤버를 가져오거나 설정합니다.

Required
사용되지 않습니다.

이 멤버는 더 이상 사용하지 않으며 아무런 기능도 갖고 있지 않습니다.

TypeId

파생 클래스에서 구현된 경우 이 Attribute에 대한 고유 식별자를 가져옵니다.

(다음에서 상속됨 Attribute)

메서드

Equals(Object)

이 인스턴스가 지정된 개체와 같은지를 나타내는 값을 반환합니다.

(다음에서 상속됨 Attribute)
GetHashCode()

이 인스턴스의 해시 코드를 반환합니다.

(다음에서 상속됨 Attribute)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
IsDefaultAttribute()

파생 클래스에서 재정의된 경우 이 인스턴스 값이 파생 클래스에 대한 기본값인지 여부를 표시합니다.

(다음에서 상속됨 Attribute)
Match(Object)

파생 클래스에서 재정의된 경우 이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다.

(다음에서 상속됨 Attribute)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1).

(다음에서 상속됨 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다.

(다음에서 상속됨 Attribute)

적용 대상

추가 정보