WCF 错误:该工厂启用了手动寻址,因此发送的所有消息都必须预先寻址
我有一个托管的 WCF 服务,我为其创建了一个自定义工厂,以便它可以与多个主机标头一起使用:
/// <summary>
/// Required for hosting where multiple host headers are present
/// </summary>
public class MultipleHostServiceFactory : ServiceHostFactory
{
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
List<Uri> addresses = new List<Uri>();
addresses.Add(baseAddresses[0]);
return base.CreateServiceHost(serviceType, addresses.ToArray());
}
}
我非常确定我的配置文件现在在客户端和服务器上都是正确的(可以在这里看到)。
我收到的错误似乎与工厂有关:
该工厂启用了手动寻址,因此发送的所有消息都必须预先寻址。
public string GetData(int value) {
return base.Channel.GetData(value);
}
错误发生在 return base.Channel.GetData(value);
行。
I've got a hosted WCF service that I created a custom factory for, so that this would work with multiple host headers:
/// <summary>
/// Required for hosting where multiple host headers are present
/// </summary>
public class MultipleHostServiceFactory : ServiceHostFactory
{
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
List<Uri> addresses = new List<Uri>();
addresses.Add(baseAddresses[0]);
return base.CreateServiceHost(serviceType, addresses.ToArray());
}
}
I'm pretty sure that my config files are now right, on both client and server (can be seen here).
The error I'm getting appears to be related to the factory:
Manual addressing is enabled on this factory, so all messages sent must be pre-addressed.
public string GetData(int value) {
return base.Channel.GetData(value);
}
The error occurs at line return base.Channel.GetData(value);
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我遇到了这个错误,并通过添加 WebHttpBehavior(下面第 2 行)解决了问题:
I experienced this error and the problem was resolved by adding the WebHttpBehavior (line 2 below):
我像往常一样添加了服务引用并收到了此错误。结果我所要做的就是修改客户端配置以使用具有指定 webhttp 行为的端点配置
I added a service reference as usual and got this error. Turns out all I had to do was to amend the client config to use an endpoint config with a behaviour specifing webhttp
我想这和你们工厂没有必然的关系。
请参阅
http://msdn.microsoft.com /en-us/library/system.servicemodel.channels.transportbindingelement.manualaddressing.aspx
或 Bing 搜索“manualaddressing”的前几个点击中的其他内容。听起来正在使用的绑定与堆栈/消息传递逻辑的其他部分不兼容。
I don't think this necessarily has anything to do with your factory.
See
http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.transportbindingelement.manualaddressing.aspx
or others among the first few Bing hits for "manualaddressing". It sounds like the binding being used is incompatible with some other portion of the stack/messaging logic.
所以这件事终于告一段落了!
布莱恩 - 感谢您对此的指导。客户端和服务器的绑定未对齐,我最终在两者中都进行了以下操作:
...并相应地设置其端点绑定和绑定配置属性:
因为这对我来说是相对较新的领域,所以只需对为什么出现这些错误的解释引导我走向正确的方向:)。
So this has finally come to an end!
Brian - thanks for your guidance on this. The bindings were mis-aligned b/t the client and server, and I finally ended up going with the following in both:
... and setting their endpoint binding and bindingConfiguration attributes accordingly:
Since this is relatively new turf for me, just the explanation of why those errors were popping up lead me in the right direction :).