更新 : 2007 年 11 月
名前空間 :
System.ServiceModel.Dispatcher
アセンブリ :
System.ServiceModel (System.ServiceModel.dll 内)
Public Interface IClientMessageInspector
Dim instance As IClientMessageInspector
public interface IClientMessageInspector
public interface class IClientMessageInspector
public interface IClientMessageInspector
public interface IClientMessageInspector
IClientMessageInspector インターフェイスを実装し、それを MessageInspectors コレクションに追加して、WCF クライアント オブジェクトを通過するメッセージを検査または変更します。詳細については、ClientRuntime のトピックを参照してください。
呼び出されたときにコンソールに文字列を出力する実装を、次のコード例に示します。
#region IClientMessageInspector Members
public void AfterReceiveReply(ref System.ServiceModel.Channels.Message reply, object correlationState)
{
Console.WriteLine("IClientMessageInspector.AfterReceiveReply called.");
Console.WriteLine("Message: {0}", reply.ToString());
}
public object BeforeSendRequest(ref System.ServiceModel.Channels.Message request, IClientChannel channel)
{
Console.WriteLine("IClientMessageInspector.BeforeSendRequest called.");
return null;
}
System.ServiceModel.Description..::.IEndpointBehavior を使用してクライアント メッセージ インスペクタをクライアントのエンドポイントに挿入する方法を、次のコード例に示します。
#region IEndpointBehavior Members
public void AddBindingParameters(
ServiceEndpoint endpoint, BindingParameterCollection bindingParameters
) { return; }
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
clientRuntime.MessageInspectors.Add(new Inspector());
foreach (ClientOperation op in clientRuntime.Operations)
op.ParameterInspectors.Add(new Inspector());
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
endpointDispatcher.DispatchRuntime.MessageInspectors.Add(new Inspector());
foreach (DispatchOperation op in endpointDispatcher.DispatchRuntime.Operations)
op.ParameterInspectors.Add(new Inspector());
}
public void Validate(ServiceEndpoint endpoint){ return; }
最後に、特定のエンドポイントでエンドポイント動作を使用するようにクライアント構成ファイルを変更する方法を、次のコード例に示します。
<client>
<endpoint
address="http://localhost:8080/SampleService"
behaviorConfiguration="clientInspectorsAdded"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_ISampleService"
contract="ISampleService"
name="WSHttpBinding_ISampleService"
>
</endpoint>
</client>
<behaviors>
<endpointBehaviors>
<behavior name="clientInspectorsAdded">
<clientInterceptors />
</behavior>
</endpointBehaviors>
</behaviors>
<extensions>
<behaviorExtensions>
<add
name="clientInterceptors"
type="Microsoft.WCF.Documentation.InspectorInserter, HostApplication, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
/>
</behaviorExtensions>
</extensions>
Windows Vista, Windows XP SP2, Windows Server 2003
.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
.NET Framework
サポート対象 : 3.5、3.0
参照