SoapExtension.Initialize(Object) Método

Definição

Quando substituído em uma classe derivada, permite que uma extensão SOAP se inicialize usando os dados armazenados em cache no método GetInitializer(LogicalMethodInfo, SoapExtensionAttribute).When overridden in a derived class, allows a SOAP extension to initialize itself using the data cached in the GetInitializer(LogicalMethodInfo, SoapExtensionAttribute) method.

public:
 abstract void Initialize(System::Object ^ initializer);
public abstract void Initialize (object initializer);
abstract member Initialize : obj -> unit
Public MustOverride Sub Initialize (initializer As Object)

Parâmetros

initializer
Object

O Object retornado do GetInitializer(LogicalMethodInfo, SoapExtensionAttribute) armazenado em cache pelo ASP.NET.The Object returned from GetInitializer(LogicalMethodInfo, SoapExtensionAttribute) cached by ASP.NET.

Exemplos

O exemplo a seguir demonstra como você pode usar os dados armazenados em cache durante o GetInitializer método.The following example demonstrates how you can use the data cached during the GetInitializer method.

   // Receive the file name stored by GetInitializer and store it in
   // a member variable for this specific instance.
public:
   virtual void Initialize( Object^ initializer ) override
   {
      filename = dynamic_cast<String^>(initializer);
   }
// Receive the file name stored by GetInitializer and store it in
// a member variable for this specific instance.
public override void Initialize(object initializer) {
    filename = (string) initializer;
}
' Receive the file name stored by GetInitializer and store it in a 
' member variable for this specific instance.
Public Overrides Sub Initialize(initializer As Object)
    m_filename = CStr(initializer)
End Sub

Comentários

Uma extensão SOAP tem três oportunidades para inicializar dados e todas têm finalidades diferentes:A SOAP extension has three opportunities to initialize data and they all have different purposes:

  • Construtor de classe-o construtor de classe é chamado sempre que uma extensão SOAP é instanciada e normalmente é usada para inicializar variáveis de membro.Class constructor - The class constructor is called every time a SOAP extension is instantiated and is typically used to initialize member variables.

  • GetInitializer -Esse método é chamado apenas uma vez, na primeira vez que uma solicitação SOAP é feita para um método XML Web Services.GetInitializer - This method is called just once, the first time a SOAP request is made to an XML Web services method. Se um atributo personalizado for aplicado ao método de serviço Web XML, o GetInitializer método será invocado.If a custom attribute is applied to the XML Web service method, the GetInitializer method is invoked. Isso permite que a extensão SOAP Interrogate o LogicalMethodInfo de um método de serviço Web XML para informações de protótipo ou acesse dados específicos de extensão passados por uma classe derivada de SoapExtensionAttribute .This allows the SOAP extension to interrogate the LogicalMethodInfo of an XML Web service method for prototype information or to access extension-specific data passed by a class deriving from SoapExtensionAttribute. O valor de retorno é armazenado em cache por ASP.NET e passado para os métodos subsequentes Initialize .The return value is cached by ASP.NET and passed into subsequent Initialize methods. Portanto, a inicialização feita no GetInitializer é encapsulada essencialmente em uma única jogada de desempenho.Therefore, initialization done in GetInitializer is encapsulated essentially into a one-time performance hit.

  • Initialize -Esse método é chamado sempre que uma solicitação SOAP é feita a um método de serviço Web XML, mas tem uma vantagem sobre o construtor de classe, no qual o Object inicializado no GetInitializer é passado para ele.Initialize - This method is called every time a SOAP request is made to an XML Web service method, but has an advantage over the class constructor, in that the Object initialized in GetInitializer is passed to it.

Observação

Você também pode adicionar uma extensão SOAP sem derivar de SoapExtensionAttribute usando o <soapExtensionTypes> elemento em um arquivo de configuração.You can also add a SOAP extension without deriving from SoapExtensionAttribute by using the <soapExtensionTypes> Element in a configuration file. Para obter detalhes, consulte modificação de <soapExtensionTypes> elemento e mensagem SOAP usando extensões SOAP.For details, see <soapExtensionTypes> Element and SOAP Message Modification Using SOAP Extensions.

Aplica-se a