How to: Initialize Cached Data When a SOAP Extension is Configured
.NET Framework 4
This topic is specific to a legacy technology. XML Web services and XML Web service clients should now be created using
Windows Communication Foundation
.
The following code example initializes a cached piece of data in the GetInitializer method, based on how the SOAP extension is eventually configured. If the SOAP extension is configured using an attribute, in this case a TraceExtensionAttribute, the file name specified in the attribute is cached. If the SOAP extension is configured using a configuration file, the cached file name is computed, based on the type of the Web service.
Example
// When the SOAP extension is accessed for the first time, the XML // Web service method it is applied to is accessed to store the file // name passed in, using the corresponding SoapExtensionAttribute. public override object GetInitializer(LogicalMethodInfo methodInfo, SoapExtensionAttribute attribute) { return ((TraceExtensionAttribute) attribute).Filename; } // The extension was configured to run using a configuration file instead of // an attribute applied to a specific Web service method. public override object GetInitializer(Type WebServiceType) { // Return a file name to log the trace information, based on the type. return "C:\\" + WebServiceType.FullName + ".log";}