【发布时间】:2011-12-26 13:31:17
【问题描述】:
在我当前的系统中,我有一个路由器服务和十几个(大约一半使用 msmq,其余使用 tcp)通过 IIS 托管的 WCF 服务。我的任务是将除路由器之外的所有服务移至 Windows 服务。这已使用与使用 IIS web.config 文件相同的配置来完成。这是之前配置的 sn-p(服务的公共队列:myservices/wcfservice):
<!--Router Service web.config-->
<client>
<endpoint address="net.msmq://localhost/MyServices/WCFService.svc" binding="netMsmqBinding" contract="*" name="IWCFService_Msmq" />
</client>
<!--Services web.config-->
<service behaviorConfiguration="SomeServiceBehavior" name="WCFService">
<endpoint binding="netMsmqBinding" name="IWCFService_Msmq"
contract="IWCFService" />
<host>
<baseAddresses>
<add baseAddress="net.msmq://localhost/MyServices/WCFService" />
</baseAddresses>
</host>
</service>
我很困惑为什么会这样,因为服务有一个 net.tcp 绑定,而路由器有 msmq,当我四处询问时,我被告知这是“神奇的”。我尝试使用类似的配置对我的设置(路由器到 Windows 服务)执行相同的操作,但收到错误消息:
<!--Router Service web.config-->
<client>
<endpoint address="net.msmq://localhost/MyServices/WCFService" binding="netMsmqBinding" contract="*" name="IWCFService_Msmq" />
</client>
<!--One "other" Services hosted in Windows Service app.config-->
<service behaviorConfiguration="SomeServiceBehavior" name="WCFService">
<endpoint binding="netMsmqBinding" name="IWCFService_Msmq"
contract="IWCFService" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost/MyServices/WCFService" />
</baseAddresses>
</host>
</service>
这对我所有使用 tcp 的服务都很好,但是当我尝试使用 msmq 并尝试启动 windows 服务时,我在事件查看器中收到以下错误:
Service cannot be started. System.InvalidOperationException: Could not find a base address that matches scheme net.msmq for the endpoint with binding NetMsmqBinding. Registered base address schemes are [net.tcp].
我是 msmq 的新手,因此不胜感激。谢谢!
更新:
我已更新服务 app.config 中的基地址以匹配路由器 web.config 中的地址。我以前试过这个,但没有奏效。后来我发现这是因为我没有使 msmq 本身成为“事务队列”(我们的设置需要它)。完成后,一切顺利!
<!--One "other" Services hosted in Windows Service app.config-->
<service behaviorConfiguration="SomeServiceBehavior" name="WCFService">
<endpoint binding="netMsmqBinding" name="IWCFService_Msmq"
contract="IWCFService" />
<host>
<baseAddresses>
<add baseAddress="net.msmq://localhost/MyServices/WCFService" />
</baseAddresses>
</host>
</service>
【问题讨论】:
标签: wcf windows-services web-config msmq