WebMethodAttribute 클래스

정의

ASP.NET을 사용하여 만든 XML Web services 내의 메서드에 이 특성을 추가하면 원격 웹 클라이언트에서 해당 메서드를 호출할 수 있습니다. 이 클래스는 상속될 수 없습니다.

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

예제

아래 예제에서 메서드 GetMachineName 는 웹 WebMethodAttribute에서 원격으로 호출할 수 있습니다. GetUserName가 없으므로 원격으로 WebMethodAttributepublic호출할 수 없습니다.

<%@ WebService Language="C#" Class="Util"%>
    using System;
    using System.Web.Services;
    public class Util: WebService {
       public string GetUserName() {
          return User.Identity.Name;
       }
    
       [ WebMethod(Description="Obtains the Server Machine Name",
       EnableSession=true)]
       public string GetMachineName() {
          return Server.MachineName;
       }
    }
<%@ WebService Language="VB" Class="Util"%>

Imports System
Imports System.Web.Services

Public Class Util
    Inherits WebService
    
    Public Function GetUserName() As String
        Return User.Identity.Name
    End Function    
    
    <WebMethod(Description := "Obtains the Server Machine Name", _
        EnableSession := True)> _
    Public Function GetMachineName() As String
        
        Return Server.MachineName
    End Function
End Class

설명

이 특성이 설정된 클래스 내의 메서드를 XML 웹 서비스 메서드라고 합니다. 메서드 및 클래스는 ASP.NET 웹 애플리케이션 내에서 실행 되 고 공용 이어야 합니다.

생성자

WebMethodAttribute()

WebMethodAttribute 클래스의 새 인스턴스를 초기화합니다.

WebMethodAttribute(Boolean)

WebMethodAttribute 클래스의 새 인스턴스를 초기화합니다.

WebMethodAttribute(Boolean, TransactionOption)

WebMethodAttribute 클래스의 새 인스턴스를 초기화합니다.

WebMethodAttribute(Boolean, TransactionOption)
WebMethodAttribute(Boolean, TransactionOption, Int32)

WebMethodAttribute 클래스의 새 인스턴스를 초기화합니다.

WebMethodAttribute(Boolean, TransactionOption, Int32)
WebMethodAttribute(Boolean, TransactionOption, Int32, Boolean)

WebMethodAttribute 클래스의 새 인스턴스를 초기화합니다.

WebMethodAttribute(Boolean, TransactionOption, Int32, Boolean)

속성

BufferResponse

이 요청에 대한 응답을 버퍼링할지 여부를 가져오거나 설정합니다.

CacheDuration

응답이 캐시에 보유되어야 하는 시간(초)을 가져오거나 설정합니다.

Description

XML Web services 메서드를 설명하는 메시지입니다.

EnableSession

XML Web services 메서드의 세션 상태 사용 여부를 나타냅니다.

MessageName

XML Web services 메서드에 전달되고 반환되는 데이터 내의 XML Web services 메서드에 사용되는 이름입니다.

TransactionOption

XML Web services 메서드의 트랜잭션 지원을 나타냅니다.

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)

적용 대상

추가 정보