1
백 엔드 서비스에 보내기 전에 WCF 라우팅 서비스의 각 메시지에 HTTP 헤더를 추가해야합니다. 나는 아래의 클래스를 구현했다. 그러나 "BeforeSendRequest"디버깅 할 때 HTTP 헤더 ic 추가되지 않습니다 따라서 호출됩니다.WCF 라우팅 서비스 IClientMessageInspector -> BeforeSendRequest 호출하지 않음
"AfterReceiveRequest"가 호출되고 HTTP 헤더를 추가했지만 헤더가 백엔드 서버로 전송되지 않는 것으로 나타났습니다.
"BeforeSendRequest"가 호출 될 때 추가해야하지만 트리거되지 않습니다.
public class RouterMessageLogger : BehaviorExtensionElement, IClientMessageInspector, IEndpointBehavior, IDispatchMessageInspector
{
public override Type BehaviorType
{
get
{
return typeof(RouterMessageLogger);
}
}
protected override object CreateBehavior()
{
return new RouterMessageLogger();
}
#region IClientMessageInspector Members
**public object BeforeSendRequest(ref Message request, IClientChannel channel)
{
Message MyMsg = request;
this.AddHTTPHeader(ref request);
//_Logging.LogMessage("Routing message to service");
return null;
}**
public void AfterReceiveReply(ref Message reply, object correlationState)
{
Message MyMsg = reply;
//_Logging.LogMessage("Response from service received");
}
#endregion
#region IDispatchMessageInspector Members
public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
{
Message MyMsg = request;
this.AddHTTPHeader(ref request);
//_Logging.LogMessage("Message received from client");
return request;
}
public void BeforeSendReply(ref Message reply, object correlationState)
{
Message MyMsg = reply;
this.AddHTTPHeader(ref reply);
//_Logging.LogMessage("Sending response to client");
}
#endregion
#region IEndpointBehavior Members
public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
{
bindingParameters.Add(this);
//return;
}
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
clientRuntime.MessageInspectors.Add(this);
clientRuntime.CallbackDispatchRuntime.ImpersonateCallerForAllOperations = true;
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
endpointDispatcher.DispatchRuntime.MessageInspectors.Add(this);
}
public void Validate(ServiceEndpoint endpoint)
{
return;
}
}
서비스에 대한 web.config (또는 app.config) 설정을 제공 할 수 있습니까? – Remotec