- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们有一个实现发现的 WCF 服务。它工作正常,但我们有一个错误处理程序,似乎在我不确定是否无效的那一刻在网络上捕获消息。使用网络监视器后,它似乎正在处理/忽略其他与发现相关的消息,而不是这个消息。
我的问题:是否有某种额外的配置可以添加到我的服务中以优雅地处理这种(类型的)消息?
我只是想知道我们是否遗漏了什么。如果没有简单的解决方案,我很乐意让我们的服务像目前一样将其作为故障处理。
错误是这样的:
System.ServiceModel.FaultException: The message with To '' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree. at System.ServiceModel.Dispatcher.ErrorBehavior.ThrowAndCatch(Exception e, Message message) Soap12 (http://www.w3.org/2003/05/soap-envelope) Addressing10 (http://www.w3.org/2005/08/addressing) HandleError: System.InvalidOperationException: The supplied message cannot be sent because the destination is unknown. This transport requires that either Message.Headers.To or Message.Properties.Via be set to a valid value on the outgoing message. at System.ServiceModel.Channels.ServerUdpOutputChannel.GetSendSockets(Message message, IPEndPoint& remoteEndPoint, Exception& exceptionToBeThrown
at System.ServiceModel.Channels.UdpOutputChannel.SendAsyncResult.Initialize(Message message
at System.ServiceModel.Channels.UdpOutputChannel.SendAsyncResult..ctor(UdpOutputChannel channel, Message message, TimeSpan timeout, AsyncCallback callback, Object state
at System.ServiceModel.Channels.UdpOutputChannel.OnBeginSend(Message message, TimeSpan timeout, AsyncCallback callback, Object state
at System.ServiceModel.Channels.OutputChannel.BeginSend(Message message, TimeSpan timeout, AsyncCallback callback, Object state
at System.ServiceModel.Dispatcher.DuplexChannelBinder.DuplexRequestContext.OnBeginReply(Message message, TimeSpan timeout, AsyncCallback callback, Object state
at System.ServiceModel.Channels.RequestContextBase.BeginReply(Message message, TimeSpan timeout, AsyncCallback callback, Object state
at System.ServiceModel.Channels.RequestContextBase.BeginReply(Message message, AsyncCallback callback, Object state
at System.ServiceModel.Dispatcher.ChannelHandler.ProvideFaultAndReplyFailure(RequestContext request, Exception exception, ErrorHandlerFaultInfo& faultInfo, Boolean& replied, Boolean& replySentAsync) HandleError: System.ServiceModel.FaultException: The message with To '' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree. at System.ServiceModel.Dispatcher.ErrorBehavior.ThrowAndCatch(Exception e, Message message) ProvideFault: System.ServiceModel.FaultException: The message with To '' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree. at System.ServiceModel.Dispatcher.ErrorBehavior.ThrowAndCatch(Exception e, Message message) Soap12 (http://www.w3.org/2003/05/soap-envelope) Addressing10 (http://www.w3.org/2005/08/addressing) HandleError: System.InvalidOperationException: The supplied message cannot be sent because the destination is unknown. This transport requires that either Message.Headers.To or Message.Properties.Via be set to a valid value on the outgoing message. at System.ServiceModel.Channels.ServerUdpOutputChannel.GetSendSockets(Message message, IPEndPoint& remoteEndPoint, Exception& exceptionToBeThrown
at System.ServiceModel.Channels.UdpOutputChannel.SendAsyncResult.Initialize(Message message
at System.ServiceModel.Channels.UdpOutputChannel.SendAsyncResult..ctor(UdpOutputChannel channel, Message message, TimeSpan timeout, AsyncCallback callback, Object state
at System.ServiceModel.Channels.UdpOutputChannel.OnBeginSend(Message message, TimeSpan timeout, AsyncCallback callback, Object state
at System.ServiceModel.Channels.OutputChannel.BeginSend(Message message, TimeSpan timeout, AsyncCallback callback, Object state
at System.ServiceModel.Dispatcher.DuplexChannelBinder.DuplexRequestContext.OnBeginReply(Message message, TimeSpan timeout, AsyncCallback callback, Object state
at System.ServiceModel.Channels.RequestContextBase.BeginReply(Message message, TimeSpan timeout, AsyncCallback callback, Object state
at System.ServiceModel.Channels.RequestContextBase.BeginReply(Message message, AsyncCallback callback, Object state
at System.ServiceModel.Dispatcher.ChannelHandler.ProvideFaultAndReplyFailure(RequestContext request, Exception exception, ErrorHandlerFaultInfo& faultInfo, Boolean& replied, Boolean& replySentAsync) HandleError: System.ServiceModel.FaultException: The message with To '' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree. at System.ServiceModel.Dispatcher.ErrorBehavior.ThrowAndCatch(Exception e, Message message)
消息如下:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsd="http://schemas.xmlsoap.org/ws/2005/04/discovery"><soap:Header><wsa:To>urn:schemas-xmlsoap-org:ws:2005:04:discovery</wsa:To><wsa:Action>http://schemas.xmlsoap.org/ws/2005/04/discovery/Resolve</wsa:Action><wsa:MessageID>urn:uuid:2729e487-0e96-42e9-a3fb-96c32c6193de</wsa:MessageID></soap:Header><soap:Body><wsd:Resolve><wsa:EndpointReference><wsa:Address>urn:uuid:1c852a4d-b800-1f08-abcd-2c59e5c16898</wsa:Address></wsa:EndpointReference></wsd:Resolve></soap:Body></soap:Envelope>
这是我基于默认 WCF 新项目模板的示例应用程序:
程序.cs:
using System;
using System.Diagnostics;
using System.Net;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Discovery;
using System.ServiceModel.Dispatcher;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
Uri baseAddress = new Uri(String.Format("net.tcp://{0}:8004/Service", Dns.Resolve(Dns.GetHostName()).HostName));
ServiceHost serviceHost = new ServiceHost(typeof(Service1), baseAddress);
// Setup the binding and open the WCF service
NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);
OptionalReliableSession reliableSession = binding.ReliableSession;
reliableSession.Enabled = false;
reliableSession.InactivityTimeout = TimeSpan.MaxValue;
binding.ReceiveTimeout = TimeSpan.MaxValue;
binding.MaxBufferSize = 1000000000;
binding.MaxReceivedMessageSize = 1000000000;
binding.MaxBufferPoolSize = 524288;
binding.TransferMode = TransferMode.Buffered;
binding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
binding.ReaderQuotas.MaxArrayLength = int.MaxValue;
binding.ReaderQuotas.MaxBytesPerRead = int.MaxValue;
ServiceEndpoint serveEnd = serviceHost.AddServiceEndpoint(typeof(IService1), binding, String.Empty);
ServiceDiscoveryBehavior serviceDiscoveryBehavior = new ServiceDiscoveryBehavior();
serviceHost.Description.Behaviors.Add(serviceDiscoveryBehavior);
UdpDiscoveryEndpoint discEnd = new UdpDiscoveryEndpoint();
serviceHost.AddServiceEndpoint(discEnd);
serviceHost.Open();
Console.WriteLine(baseAddress);
Debug.WriteLine(baseAddress);
Console.Read();
}
catch (Exception ex)
{
Debug.WriteLine(ex);
//throw;
}
}
}
}
IService1.cs 和 Service1.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace ConsoleApplication1
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(int value);
[OperationContract]
CompositeType GetDataUsingDataContract(CompositeType composite);
// TODO: Add your service operations here
}
// Use a data contract as illustrated in the sample below to add composite types to service operations.
[DataContract]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello ";
[DataMember]
public bool BoolValue
{
get { return boolValue; }
set { boolValue = value; }
}
[DataMember]
public string StringValue
{
get { return stringValue; }
set { stringValue = value; }
}
}
}
using System;
using System.Diagnostics;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace ConsoleApplication1
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
public class Service1 : IService1, IErrorHandler, IServiceBehavior
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
public CompositeType GetDataUsingDataContract(CompositeType composite)
{
if (composite == null)
{
throw new ArgumentNullException("composite");
}
if (composite.BoolValue)
{
composite.StringValue += "Suffix";
}
return composite;
}
public bool HandleError(Exception error)
{
Debug.WriteLine("HandleError: {0}", error);
Console.WriteLine("HandleError: {0}", error);
return false;
}
public void ProvideFault(Exception error, System.ServiceModel.Channels.MessageVersion version, ref System.ServiceModel.Channels.Message fault)
{
Debug.WriteLine("ProvideFault: {0} {1}", error, version);
Console.WriteLine("ProvideFault: {0} {1}", error, version);
}
#region IServiceBehavior Members
public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
{
return;
}
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
foreach (ChannelDispatcher channelDispatcher in serviceHostBase.ChannelDispatchers)
{
channelDispatcher.ErrorHandlers.Add(this);
}
}
public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
return;
}
#endregion
}
}
干杯,克里斯。
最佳答案
我遇到了同样的问题:一切正常,但发现端点不断向无处发送消息,大约每 5 分钟一次,导致 2 个异常,如跟踪消息所示。
我设法找出预配置的端点具有契约(Contract)名称 TargetService 和地址 urn:docs-oasis-open-org:ws-dd:ns:discovery:2009:01。我用谷歌搜索了一下,没有发现任何线程提到这个。
我倾向于认为这是此 WCF 预配置端点中的一个缺陷。
我使用了与 Chris 类似的解决方法。
我有一个 Ping 服务,它有自己的类和服务主机,这个类不会与错误处理程序 Hook ,因此不会向日志文件发出神秘的错误消息。其他业务功能转到其他类和另一个服务主机,与错误处理程序 Hook 以捕获未捕获的异常。
此外,因为端点发现比直接寻址慢大约 200 倍,所以我有一个包装类来缓冲通过发现在第一个 Ping 中找到的基地址。随后的客户端调用将使用该地址。
关于c# - WCF 服务故障处理 WS-Discovery Resolve 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18631284/
有人可以解释一下为什么这个脚本不起作用吗? function destroy(ID) { if (confirm("Deleting is a very bad thing! Sure?")
我正在尝试使 WCF Silverlight 故障按此方式工作: MSDN aricle 将 SL 故障添加到我的 Web.config 文件后,我收到以下警告: The element 'behav
这是我要删除的 Haskell 函数 2::Int和 5::Int从列表中: remPrimesFactors25 :: [Int] -> [Int] remPrimesFactors25 [] =
当我想用 ffmpeg 连接和录制两个 mp4 视频时,我遇到了这个问题。我得到的输出是: [concat @ 0x2566e80] DTS 4079 #0:0 (h264 (native) ->
我想在delphi中编写一个程序来模拟以特定速度移动的鼠标指针(类似于AutoIT MouseMove函数)。要么是我的代码错误,要么是 SetCursorPos 在被调用太多次后出现故障。这是我的功
我将“wa、or 和 id”(来自这些州的访问者)设置为重定向到 website1.com - 当我访问该网站时,它会将我重定向到 website1.com(因此它知道我在 WA) 。但如果我将 wa
我们目前正在争论通过 WCF channel 抛出错误与传递指示状态或服务响应的消息是否更好。 故障带有 WCF 的内置支持,您可以使用内置的错误处理程序并做出相应的 react 。然而,这会带来开销
不确定我在这里做错了什么,如果有任何帮助,我们将不胜感激。 尝试创建一个名为“control”的新变量,并在行变量等于这些数字时将其编码为 1,否则编码为 0。 data$control= ifels
我想在应用洞察中记录成功调用的百分比。我看到这篇文章https://learn.microsoft.com/en-us/azure/azure-monitor/app/sampling我认为固定速率采
我正在尝试使用 SVD 和特征分解来使用动态模式分解进行一些数据分析。我遇到了一个简单的问题,即从 Matlab 和 Python 获得不同的结果。我很困惑,不知道为什么 Python 给我错误的结果
This question already has an answer here: mysqli_fetch_assoc() expects parameter / Call to a member
我刚刚开始我的一个实验室,在那里我计算类(class)的 GPA,其信息存储在结构的链接列表中。截至目前,我正在尝试打印所有类(class)信息,以确保它们已正确初始化并添加到链接列表中。 我遇到了一
我正在尝试学习如何使用 visual studio 为 C++ 制作 GUI。但是我在使用 GetWindowText() 函数时遇到了一些问题。它不会将 LPTSTR 标题更改为文本框中的文本,并且
我有一个奇怪的问题。它似乎只出现在测试者的 iPhone 5s 上。它可以在运行最新 iOS (8.3) 的 iPhone 5、6 和 6 plus 上正常运行。 这是代码 -(NSString *)
我正在尝试更新 Core Data 中的一些记录。我正在采取以下步骤来完成它 带谓词的获取函数从核心数据中检索记录 将结果集存储在对象数组中 遍历数组并更新每条记录 调用保存上下文 我遇到了两个问题
我通过 Storyboard设计了 tableView,在一个单元格中我有一个按钮和一个标签。按钮在 Storyboard上有标签 1 和标签在 Storyboard上有标签 2。在 cellForR
我实现了这个方法,当在文本字段中输入了未经授权的字符或已使用的用户名时,向用户发送多个警报 View : func textFieldShouldEndEditing(textField: UITex
伙计们,我在运行程序时遇到了这个非常奇怪的错误。这是重要的代码: 变量(编辑): const short int maxX = 100; const short int maxZ = 100; con
我有这个修改过的 Matrix Javascript 代码,我想摆脱第一次运行的所有与自身重叠的字符串。有人知道我该如何管理吗?另外,我想在我的网页上多次使用此代码,我需要声明新变量,不是吗?但是当我
有谁知道是否有网站(甚至非 Microsoft)有关于 COMExceptions/HRESULTS 的详细信息。 当我尝试在使用 Copy() 函数后保存我的 Excel 工作簿时,我收到此错误:
我是一名优秀的程序员,十分优秀!