0
反序列化並以可讀格式顯示應用程序和使用CSLA.Net的服務器之間的通信的最快方法是什麼?反序列化/解碼CSLA.Net請求和響應
反序列化並以可讀格式顯示應用程序和使用CSLA.Net的服務器之間的通信的最快方法是什麼?反序列化/解碼CSLA.Net請求和響應
如果您使用的是WCF,則應該能夠將自定義終結點行爲添加到客戶端上的app.config文件中。
創建自定義消息檢查(例如這裏只記錄到輸出窗口或跟蹤):
public class OutputMessageInspector : IClientMessageInspector
{
public object BeforeSendRequest(ref Message request, IClientChannel channel)
{
Debug.WriteLine("Request XML: ");
Debug.WriteLine(request.ToString() ?? "<NULL>");
return null;
}
public void AfterReceiveReply(ref Message reply, object correlationState)
{
Debug.WriteLine("Response XML: ");
Debug.WriteLine(reply.ToString() ?? "<NULL>");
}
}
這消息檢查添加到自定義端點行爲:
public class CustomMessageInspectorBehavior : IEndpointBehavior
{
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
clientRuntime.MessageInspectors.Add(new OutputMessageInspector());
}
public void Validate(ServiceEndpoint endpoint) { }
public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) { }
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) { }
}
現在只需更新您的app.config WCF配置將CustomMessageInspectorBehavior
添加爲端點行爲。 See MSDN
你想完成什麼? –