This documentation is archived and is not being maintained.

SoapExtension::GetInitializer Method (Type)

When overridden in a derived class, allows a SOAP extension to initialize data specific to a class implementing an XML Web service at a one time performance cost.

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

public:
virtual Object^ GetInitializer(
	Type^ serviceType
) abstract

Parameters

serviceType
Type: System::Type
The type of the class implementing the XML Web service to which the SOAP extension is applied.

Return Value

Type: System::Object
The Object that the SOAP extension initializes for caching.

The overload of GetInitializer that gets called by ASP.NET depends on how the SOAP extension was specified. There are two methods for specifying a SOAP extension:

  • Apply a custom attribute, deriving from SoapExtensionAttribute, to the individual XML Web service method.

  • Add a reference in either the web.config or app.config configuration files.

If you add a reference to one of the configuration files, the SOAP extension runs for all XML Web services within the scope of that configuration file. When specifying, a SOAP extension by referencing a configuration file, ASP.NET invokes the GetInitializer overload that passes in a Type. When specifying an extension by applying a custom attribute, ASP.NET invokes the GetInitializer that passes in a LogicalMethodInfo and a SoapExtensionAttribute.

For details on adding SOAP extensions to a configuration file, see [<topic://cpconconfigurationoptionsforaspnetwebservices>].

The following code demonstrates how one can save SOAP extension specific data on a per XML Web service basis. If the SOAP extension is configured using a configuration file instead of an attribute, the SOAP extension can store data for each class to which the SOAP extension is applied. This example saves the name of a file in which to log the SOAP messages sent to and from the XML Web service method based on the name of the class implementing the XML Web service into the cache. This code example is part of a full code example for a TraceExtension SOAP extension that can be found in the SoapExtension class overview.


   // 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 );
   }


.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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