다음을 통해 공유


SoapExtension.GetInitializer 메서드

정의

파생 클래스에서 재정의된 경우 SOAP 확장에서 단일 성능 비용으로 XML Web services 메서드와 관련된 데이터를 초기화할 수 있습니다.

오버로드

GetInitializer(Type)

파생 클래스에서 재정의된 경우 SOAP 확장에서 단일 성능 비용으로 XML Web services를 구현하는 클래스와 관련된 데이터를 초기화할 수 있습니다.

GetInitializer(LogicalMethodInfo, SoapExtensionAttribute)

파생 클래스에서 재정의된 경우 SOAP 확장에서 단일 성능 비용으로 XML Web services 메서드에 적용된 특성을 사용하여 XML Web services 메서드와 관련된 데이터를 초기화할 수 있습니다.

GetInitializer(Type)

파생 클래스에서 재정의된 경우 SOAP 확장에서 단일 성능 비용으로 XML Web services를 구현하는 클래스와 관련된 데이터를 초기화할 수 있습니다.

public:
 abstract System::Object ^ GetInitializer(Type ^ serviceType);
public abstract object GetInitializer (Type serviceType);
abstract member GetInitializer : Type -> obj
Public MustOverride Function GetInitializer (serviceType As Type) As Object

매개 변수

serviceType
Type

SOAP 확장이 적용되는 XML Web services를 구현하는 클래스의 형식입니다.

반환

캐시하기 위해 SOAP 확장이 초기화하는 Object입니다.

예제

다음 코드에서는 XML 웹 서비스별로 SOAP 확장 특정 데이터를 저장하는 방법을 보여 줍니다. SOAP 확장이 특성 대신 구성 파일을 사용하여 구성된 경우 SOAP 확장은 SOAP 확장이 적용되는 각 클래스에 대한 데이터를 저장할 수 있습니다. 이 예제에서는 XML 웹 서비스를 구현하는 클래스의 이름을 기반으로 XML 웹 서비스 메서드에서 전송된 SOAP 메시지를 캐시에 기록할 파일의 이름을 저장합니다. 이 코드 예제는 클래스 개요에서 찾을 수 있는 TraceExtension SOAP 확장에 대한 전체 코드 예제의 SoapExtension 일부입니다.

   // The extension was configured to run using a configuration file instead of an attribute applied to a 
   // specific XML Web service method. Return a file name based on the class implementing the XML Web service's type.
public:
   virtual Object^ GetInitializer( Type^ WebServiceType ) override
   {
      // Return a file name to log the trace information to based on the passed in type.
      return String::Format( "C:\\{0}.log", WebServiceType->FullName );
   }
// The extension was configured to run using a configuration file instead of an attribute applied to a
// specific XML Web service method. Return a file name based on the class implementing the XML Web service's type.
public override object GetInitializer(Type WebServiceType)
{
   // Return a file name to log the trace information to based on the passed in type.
   return "C:\\" + WebServiceType.FullName + ".log";
}
' The extension was configured to run using a configuration file instead of an attribute applied to a 
' specific XML Web service method.  Return a file name based on the class implementing the XML Web service's type.
Public Overloads Overrides Function GetInitializer(WebServiceType As Type) As Object
   ' Return a file name to log the trace information to based on the passed in type.
    Return "C:\" + WebServiceType.FullName + ".log"
End Function

설명

ASP.NET 호출되는 의 GetInitializer 오버로드는 SOAP 확장이 지정된 방법에 따라 달라집니다. SOAP 확장을 지정하는 방법에는 두 가지가 있습니다.

  • 에서 SoapExtensionAttribute파생된 사용자 지정 특성을 개별 XML 웹 서비스 메서드에 적용합니다.

  • web.config 또는 app.config 구성 파일에 참조를 추가합니다.

구성 파일 중 하나에 대한 참조를 추가하는 경우 SOAP 확장은 해당 구성 파일 범위 내의 모든 XML 웹 서비스에 대해 실행됩니다. 구성 파일을 참조하여 SOAP 확장을 지정할 때 ASP.NET 에 전달되는 오버로드를 Type호출 GetInitializer 합니다. 사용자 지정 특성을 적용하여 확장을 지정할 때 ASP.NET 및 SoapExtensionAttribute에 전달되는 를 LogicalMethodInfo 호출 GetInitializer 합니다.

구성 파일에 SOAP 확장을 추가하는 방법에 대한 자세한 내용은 ASP.NET 사용하여 만든 XML Web Services에 대한 구성 옵션을 참조하세요.

적용 대상

GetInitializer(LogicalMethodInfo, SoapExtensionAttribute)

파생 클래스에서 재정의된 경우 SOAP 확장에서 단일 성능 비용으로 XML Web services 메서드에 적용된 특성을 사용하여 XML Web services 메서드와 관련된 데이터를 초기화할 수 있습니다.

public:
 abstract System::Object ^ GetInitializer(System::Web::Services::Protocols::LogicalMethodInfo ^ methodInfo, System::Web::Services::Protocols::SoapExtensionAttribute ^ attribute);
public abstract object GetInitializer (System.Web.Services.Protocols.LogicalMethodInfo methodInfo, System.Web.Services.Protocols.SoapExtensionAttribute attribute);
abstract member GetInitializer : System.Web.Services.Protocols.LogicalMethodInfo * System.Web.Services.Protocols.SoapExtensionAttribute -> obj
Public MustOverride Function GetInitializer (methodInfo As LogicalMethodInfo, attribute As SoapExtensionAttribute) As Object

매개 변수

methodInfo
LogicalMethodInfo

SOAP 확장이 적용되는 XML Web services 메서드에 대한 특정 함수 프로토타입을 나타내는 LogicalMethodInfo입니다.

attribute
SoapExtensionAttribute

XMl Web services 메서드에 적용되는 SoapExtensionAttribute입니다.

반환

캐시하기 위해 SOAP 확장이 초기화하는 Object입니다.

예제

다음 코드에서는 에서 SoapExtensionAttribute파생된 클래스를 사용하여 전달된 SOAP 확장 관련 데이터를 가져온 다음 에서 해당 데이터를 GetInitializer캐시하는 방법을 보여 줍니다. 이 코드 예제는 클래스 개요에서 찾을 수 있는 TraceExtension SOAP 확장에 대한 전체 코드 예제의 SoapExtension 일부입니다. 이 코드 예제에서는 매개 변수에 전달되는 를 attribute 사용합니다TraceExtensionAttribute. 전체 코드 예제 TraceExtensionAttribute 에서 에서 파생 SoapExtensionAttribute 되고 캐시에 저장되는 GetInitializer 속성을 추가합니다Filename.

public:
   // When the SOAP extension is accessed for the first time, cache the 
   // file name passed in by the SoapExtensionAttribute.    
   virtual Object^ GetInitializer( LogicalMethodInfo^ /*methodInfo*/, SoapExtensionAttribute^ attribute ) override
   {
      return (dynamic_cast<TraceExtensionAttribute^>(attribute))->Filename;
   }
// When the SOAP extension is accessed for the first time, cache the
// file name passed in by the SoapExtensionAttribute.
public override object GetInitializer(LogicalMethodInfo methodInfo,
    SoapExtensionAttribute attribute)
{
    return ((TraceExtensionAttribute) attribute).Filename;
}
' When the SOAP extension is accessed for the first time, 
' cache the file name passed in by the SoapExtensionAttribute.

Public Overloads Overrides Function GetInitializer( _
    methodInfo As LogicalMethodInfo, _
    attribute As SoapExtensionAttribute) As Object    
    Return CType(attribute, TraceExtensionAttribute).Filename
End Function

설명

구성 파일을 사용하여 SOAP 확장이 구성된 경우 을 GetInitializer 허용하는 오버로드가 Type표시됩니다.

SOAP 확장에는 데이터를 초기화할 수 있는 세 가지 기회가 있으며 모두 다른 용도로 사용됩니다.

  • 클래스 생성자 - 클래스 생성자는 SOAP 확장이 인스턴스화될 때마다 호출되며 일반적으로 멤버 변수를 초기화하는 데 사용됩니다.

  • GetInitializer - GetInitializer그러나 은 XML 웹 서비스 메서드에 대한 SOAP 요청이 처음으로 한 번만 호출됩니다. 사용자 지정 특성이 XML 웹 서비스 메서드에 적용되면 메서드가 GetInitializer 호출됩니다. 이렇게 하면 SOAP 확장에서 프로토타입 정보를 위해 XML 웹 서비스 메서드의 를 심문 LogicalMethodInfo 하거나 에서 파생된 클래스에서 SoapExtensionAttribute전달된 확장 관련 데이터에 액세스할 수 있습니다. 반환 값은 ASP.NET 의해 캐시되고 후속 Initialize 메서드로 전달됩니다. 따라서 에서 GetInitializer 수행된 초기화는 기본적으로 일회성 성능 적중으로 캡슐화됩니다.

  • Initialize - Initialize는 XML 웹 서비스 메서드에 SOAP 요청이 이루어질 때마다 호출되지만 에서 초기화된 GetInitializer 가 전달된다는 측면에서 Object 클래스 생성자에 비해 이점이 있습니다.

추가 정보

적용 대상