This documentation is archived and is not being maintained.

IWsdlImportExtension.ImportContract Method

Called when importing a contract.

Namespace: System.ServiceModel.Description
Assembly: System.ServiceModel (in system.servicemodel.dll)

void ImportContract (
	WsdlImporter importer,
	WsdlContractConversionContext context
void ImportContract (
	WsdlImporter importer, 
	WsdlContractConversionContext context
function ImportContract (
	importer : WsdlImporter, 
	context : WsdlContractConversionContext
Not applicable.



The importer.


The import context to be modified.

The ImportContract method is called when a contract is being imported. You can modify the contract or insert other exporting behaviors such as System.ServiceModel.Description.IServiceContractGenerationExtension and an System.ServiceModel.Description.IOperationContractGenerationExtension objects to modify the code that is generated for the contract.

The following code example shows the use of IWsdlImportExtension to add an System.ServiceModel.Description.IServiceContractGenerationExtension and an System.ServiceModel.Description.IOperationContractGenerationExtension (the WsdlDocumentationImporter, in this case) to modify generated WCF client code at the interface and operation level.

  public void ImportContract(WsdlImporter importer, WsdlContractConversionContext context)
      // Contract Documentation
      if (context.WsdlPortType.Documentation != null)
  context.Contract.Behaviors.Add(new WsdlDocumentationImporter(context.WsdlPortType.Documentation));
      // Operation Documentation
      foreach (Operation operation in context.WsdlPortType.Operations)
          if (operation.Documentation != null)
              OperationDescription operationDescription = context.Contract.Operations.Find(operation.Name);
              if (operationDescription != null)
      operationDescription.Behaviors.Add(new WsdlDocumentationImporter(operation.Documentation));

The following code example shows how to configure the client metadata system to use the custom IWsdlImportExtension from an application configuration file.

          <extension type="Microsoft.WCF.Documentation.WsdlDocumentationImporter, WsdlDocumentation, Version=, Culture=neutral, PublicKeyToken=null" />

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