SchemaImporterExtension Class


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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


Initializes a new instance of the SchemaImporterExtension class.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodImportAnyElement(XmlSchemaAny, Boolean, XmlSchemas, XmlSchemaImporter, CodeCompileUnit, CodeNamespace, CodeGenerationOptions, CodeDomProvider)

Handles the importation of the <xsd:any> elements in the schema.

System_CAPS_pubmethodImportDefaultValue(String, String)

Allows you to specify the default value for the XSD type being imported.

System_CAPS_pubmethodImportSchemaType(String, String, XmlSchemaObject, XmlSchemas, XmlSchemaImporter, CodeCompileUnit, CodeNamespace, CodeGenerationOptions, CodeDomProvider)

Allows you to manipulate the code generated by examining the imported schema and specifying the CLR type that it maps to.

System_CAPS_pubmethodImportSchemaType(XmlSchemaType, XmlSchemaObject, XmlSchemas, XmlSchemaImporter, CodeCompileUnit, CodeNamespace, CodeGenerationOptions, CodeDomProvider)

Allows you to manipulate the code generated by examining the imported schema and specifying the CLR type that it maps to.


Creates a shallow copy of the current Object.(Inherited from Object.)


Returns a string that represents the current object.(Inherited from Object.)

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.

.NET Framework
Available since 2.0

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

Return to top