|
Cet article a fait l'objet d'une traduction automatique. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. Informations supplémentaires.
|
Traduction
Source
|
IEndpointBehavior, interface
Espace de noms : System.ServiceModel.Description
Assembly : System.ServiceModel (dans System.ServiceModel.dll)
Le type IEndpointBehavior expose les membres suivants.
| Nom | Description | |
|---|---|---|
![]() ![]() | AddBindingParameters | |
![]() ![]() | ApplyClientBehavior | |
![]() ![]() | ApplyDispatchBehavior | |
![]() ![]() | Validate |
Utilisez la méthode AddBindingParameters pour passer des données personnalisées lors de l'exécution pour permettre aux liaisons de prendre en charge un comportement personnalisé. Utilisez la méthode ApplyClientBehavior pour modifier, examiner ou insérer des extensions à un point de terminaison d'une application cliente. Utilisez la méthode ApplyDispatchBehavior pour modifier, examiner ou insérer des extensions à l'exécution à l'échelle du point de terminaison d'une application de service. Utilisez la méthode Validate pour confirmer qu'un ServiceEndpoint remplit les conditions requises. Elle permet d'assurer qu'un point de terminaison dispose d'un certain paramètre de configuration activé, qu'il prend en charge une fonctionnalité particulière et d'autres spécifications.
Remarque |
|---|
Par programme, ajoutez le comportement de point de terminaison personnalisé à la propriété Behaviors avant l'ouverture de l'hôte de service (dans une application de service) ou de la fabrique de canal (dans une application cliente). Configurez le comportement à l'aide d'un fichier de configuration de l'application. Pour plus d'informations, consultez <behaviorExtensions>.
// IDispatchMessageInspector Members public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, IClientChannel channel, InstanceContext instanceContext) { Console.WriteLine("AfterReceiveRequest called."); return null; } public void BeforeSendReply(ref System.ServiceModel.Channels.Message reply, object correlationState) { Console.WriteLine("BeforeSendReply called."); }
// IEndpointBehavior Members public void AddBindingParameters(ServiceEndpoint serviceEndpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters) { return; } public void ApplyClientBehavior(ServiceEndpoint serviceEndpoint, ClientRuntime behavior) { behavior.MessageInspectors.Add(new EndpointBehaviorMessageInspector()); } public void ApplyDispatchBehavior(ServiceEndpoint serviceEndpoint, EndpointDispatcher endpointDispatcher) { endpointDispatcher.DispatchRuntime.MessageInspectors.Add(new EndpointBehaviorMessageInspector()); } public void Validate(ServiceEndpoint serviceEndpoint) { return; }
// BehaviorExtensionElement members public override Type BehaviorType { get { return typeof(EndpointBehaviorMessageInspector); } } protected override object CreateBehavior() { return new EndpointBehaviorMessageInspector(); }
<configuration>
<system.serviceModel>
<services>
<service
name="Microsoft.WCF.Documentation.SampleService"
behaviorConfiguration="metadataSupport"
>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/ServiceMetadata" />
</baseAddresses>
</host>
<endpoint
address="/SampleService"
binding="wsHttpBinding"
behaviorConfiguration="withMessageInspector"
contract="Microsoft.WCF.Documentation.ISampleService"
/>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"
/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metadataSupport">
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="withMessageInspector">
<endpointMessageInspector />
</behavior>
</endpointBehaviors>
</behaviors>
<extensions>
<behaviorExtensions>
<add
name="endpointMessageInspector"
type="Microsoft.WCF.Documentation.EndpointBehaviorMessageInspector, HostApplication, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
/>
</behaviorExtensions>
</extensions>
</system.serviceModel>
</configuration>
<configuration>
<system.serviceModel>
<services>
<service
name="Microsoft.WCF.Documentation.SampleService"
behaviorConfiguration="metadataSupport"
>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/ServiceMetadata" />
</baseAddresses>
</host>
<endpoint
address="/SampleService"
binding="wsHttpBinding"
behaviorConfiguration="withMessageInspector"
contract="Microsoft.WCF.Documentation.ISampleService"
/>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"
/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metadataSupport">
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="withMessageInspector">
<endpointMessageInspector />
</behavior>
</endpointBehaviors>
</behaviors>
<extensions>
<behaviorExtensions>
<add
name="endpointMessageInspector"
type="Microsoft.WCF.Documentation.EndpointBehaviorMessageInspector, HostApplication, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
/>
</behaviorExtensions>
</extensions>
</system.serviceModel>
</configuration>
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (rôle principal du serveur non pris en charge), Windows Server 2008 R2 (rôle principal du serveur pris en charge avec SP1 ou version ultérieure ; Itanium non pris en charge)
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

