SchemaImporterExtension Class

Allows you to customize the code generated from a Web Services Description Language (WSDL) document when using automated query tools.

Namespace: System.Xml.Serialization.Advanced
Assembly: System.Xml (in system.xml.dll)

public abstract class SchemaImporterExtension
public abstract class SchemaImporterExtension
public abstract class SchemaImporterExtension
Not applicable.

Schema importation occurs whenever a Web service proxy is produced through a tool such as the Add Web Reference dialog box found in Visual Studio, or by using the Web Services Description Language Tool (Wsdl.exe). Schema importation also occurs when using the XML Schema Definition Tool (Xsd.exe) to generate code from a specific XSD document.

The SchemaImporterExtension class allows you to modify the code generated when using any of these tools. For example, you may have an existing class that processes book orders on a system and you have an existing XSD document that supplies your orders. Using the SchemaImporterExtension class, you can enable one of the tools to generate code that uses your class.

In order to control the generation of the code, you must use the classes found in the System.CodeDom namespace. For more information, see Using the CodeDOM and CodeDOM Quick Reference.

The steps to enabling the WSDL.exe tool (which in turn is used by other tools such as the Add Web Reference dialog box) to use your extension are:

  1. Create an implementation of the SchemaImporterExtension class.

  2. Use the ImportSchemaType method to write code for the code generator. The method contains parameters that allow you to examine the intercepted XSD type and create CodeDOM objects that are used to generate the new CLR code.

  3. If required, use the ImportAnyElement method to handle <xsd:any> elements found in the XSD document.

  4. If required, use the ImportDefaultValue method to examine default values found in the XSD document and return a different default value.

  5. Compile your extension into a library.

  6. Sign the assembly.

  7. Install the assembly in the Global Assembly Cache (GAC).

  8. Modify the machine.config file to include the extension.

See the SchemaImporterExtension Technology Sample. Note that this example does not include a signed assembly. Instead, it demonstrates how to use the SchemaImporterExtension with a command window.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, 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