IWsdlImportExtension Interface
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Implement and attach to a WsdlImporter object to control how the importer maps Web Services Description Language (WSDL) parts to those of a ServiceDescription object.
public interface class IWsdlImportExtension
public interface IWsdlImportExtension
type IWsdlImportExtension = interface
Public Interface IWsdlImportExtension
- Derived
Examples
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)
{
Console.Write("ImportContract");
// 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.
<system.serviceModel>
<client>
<endpoint
address="http://localhost:8000/Fibonacci"
binding="wsHttpBinding"
contract="IFibonacci"
/>
<metadata>
<wsdlImporters>
<extension type="Microsoft.WCF.Documentation.WsdlDocumentationImporter, WsdlDocumentation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</wsdlImporters>
</metadata>
</client>
</system.serviceModel>
Remarks
Implement the IWsdlImportExtension interface to control the mapping between WSDL and ServiceEndpoint and ContractDescription objects, especially when reading custom WSDL extensions to modify your contract or endpoint information. Then attach your custom IWsdlImportExtension object to a WsdlImporter either programmatically or by using an application configuration file. You can also attach your custom IWsdlImportExtension object to the internal WsdlImporter used by the ServiceModel Metadata Utility Tool (Svcutil.exe) using an application configuration file.
The ImportContract method is called to import a contract.
Use the BeforeImport method to modify the metadata that is then imported into ServiceEndpoint and ContractDescription objects.
Methods
BeforeImport(ServiceDescriptionCollection, XmlSchemaSet, ICollection<XmlElement>) |
Called prior to importing metadata documents. |
ImportContract(WsdlImporter, WsdlContractConversionContext) |
Called when importing a contract. |
ImportEndpoint(WsdlImporter, WsdlEndpointConversionContext) |
Called when importing an endpoint. |
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기