SoapExtension.Initialize Method
When overridden in a derived class, allows a SOAP extension to initialize itself using the data cached in the GetInitializer method.
[Visual Basic] Public MustOverride Sub Initialize( _ ByVal initializer As Object _ ) [C#] public abstract void Initialize( object initializer ); [C++] public: virtual void Initialize( Object* initializer ) = 0; [JScript] public abstract function Initialize( initializer : Object );
Parameters
- initializer
- The Object returned from GetInitializer cached by ASP.NET.
Remarks
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.
Example
[Visual Basic, C#, C++] The following example demonstrates how you can use the data cached during the GetInitializer method.
[Visual Basic] ' 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 [C#] // 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; } [C++] // Receive the file name stored by GetInitializer and store it in // a member variable for this specific instance. public: void Initialize(Object* initializer) { filename = dynamic_cast<String*> (initializer); }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
See Also
SoapExtension Class | SoapExtension Members | System.Web.Services.Protocols Namespace