Export (0) Print
Expand All

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

The SchemaImporterExtension type exposes the following members.

  NameDescription
Protected methodSchemaImporterExtensionInitializes a new instance of the SchemaImporterExtension class.
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodImportAnyElementHandles the importation of the <xsd:any> elements in the schema.
Public methodImportDefaultValueAllows you to specify the default value for the XSD type being imported.
Public methodImportSchemaType(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.
Public methodImportSchemaType(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.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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

Supported in: 4, 3.5, 3.0, 2.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.

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

Community Additions

ADD
Show:
© 2014 Microsoft