public override bool Match(System.ServiceModel.Channels.Message message) { //wHaibo 2013-05-14 Action再调整 ActionMessageFilter actionFilter = filter as ActionMessageFilter; if (actionFilter != null) { if (!actionFilter.Actions.Contains(message.Headers.Action) && message.Headers.Action != null) { string oldAction = message.Headers.Action; string actionName = actionFilter.Actions.FirstOrDefault(x => x.EndsWith(message.Headers.Action)); if (String.IsNullOrEmpty(actionName)) { actionName = actionFilter.Actions.FirstOrDefault(x => x.EndsWith(message.Headers.Action + "Request")); } if (!String.IsNullOrEmpty(actionName)) { message.Headers.Action = actionName; receiveLogger.Trace("调整Action:{0}---->{1}", oldAction, message.Headers.Action); } } } bool isMatch = filter.Match(message); if (!isMatch) { receiveLogger.Error("收到消息,但是Action不匹配:\r\n地址:{0} \r\n消息:\r\n{1}\r\n", address.Uri.ToString(), message.ToString()); } return(isMatch); }
public override bool Match(System.ServiceModel.Channels.Message message) { if (String.IsNullOrEmpty(message.Headers.Action)) { if (message.Headers.To != null) { if (!String.IsNullOrEmpty(message.Headers.To.Query)) { if (message.Headers.To.Query.StartsWith("?op=", StringComparison.OrdinalIgnoreCase)) { message.Headers.Action = message.Headers.To.Query.Substring(4).Trim(); receiveLogger.Info("调整Action:{0} 请求地址:{1}", message.Headers.Action, message.Headers.To.ToString()); } } else { string requestUrl = message.Headers.To.ToString(); string serviceUrl = address.Uri.ToString(); if (!serviceUrl.Equals(requestUrl, StringComparison.OrdinalIgnoreCase) && requestUrl.Length > serviceUrl.Length && requestUrl.StartsWith(serviceUrl, StringComparison.OrdinalIgnoreCase)) { string action = requestUrl.Substring(serviceUrl.Length + 1); message.Headers.Action = action; message.Headers.To = new Uri(serviceUrl); receiveLogger.Info("调整Action:{0} 请求地址:{1}", message.Headers.Action, requestUrl); } } } } if (message.Headers.To == null) { message.Headers.To = this.address.Uri; } bool isMatch = filter.Match(message); return(isMatch); }