SoapExtension.Initialize Method

When overridden in a derived class, allows a SOAP extension to initialize itself using the data cached in the GetInitializer method.

Namespace:  System.Web.Services.Protocols
Assembly:  System.Web.Services (in System.Web.Services.dll)

public abstract void Initialize(
	Object initializer
)

Parameters

initializer
Type: System.Object

The Object returned from GetInitializer cached by ASP.NET.

A SOAP extension has three opportunities to initialize data and they all have different purposes:

  • Class constructor - The class constructor is called every time a SOAP extension is instantiated and is typically used to initialize member variables.

  • GetInitializer - GetInitializer, however, is called just once, the first time a SOAP request is made to an XML Web services method. If a custom attribute is applied to the XML Web service method, the GetInitializer method is invoked. 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. The return value is cached by ASP.NET and passed into subsequent Initialize methods. Therefore, initialization done in GetInitializer is encapsulated essentially into a one-time performance hit.

  • Initialize - Initialize 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.

NoteNote

You can also add a SOAP extension without deriving from SoapExtensionAttribute by using the <soapExtensionTypes> Element in a configuration file. For details, see <soapExtensionTypes> Element and SOAP Message Modification Using SOAP Extensions.

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 override void Initialize(object initializer) {
    filename = (string) initializer;
}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft