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
public abstract Object GetInitializer (
	Type serviceType
)
public abstract function GetInitializer (
	serviceType : Type
) : Object
Not applicable.

Parameters

serviceType

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

Return Value

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 Configuration Options for XML Web Services Created Using ASP.NET.

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

// 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 Object GetInitializer(Type WebServiceType)
{
    // Return a file name to log the trace information to based on the 
    // passed in type.
    return "C:\\" + WebServiceType.get_FullName() + ".log";
} //GetInitializer

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show: