c# - WCF:客户端 > 端点 > 错误:工作 URL 上的 URI 无效
问题描述
我正在设置 WCF 自托管解决方案以用作 WCF 路由器,但在启动服务时遇到了一些麻烦。
申请代码是
public class Program
{
static void Main(string[] args)
{
ServiceHost routingHost = new ServiceHost(typeof(RoutingService));
routingHost.Open();
Console.WriteLine("Routing Service is running");
Console.WriteLine("Press [Enter] to exit");
Console.ReadLine();
routingHost.Close();
}
}
App.Config 服务部分是
<system.serviceModel>
<services>
<service name="System.ServiceModel.Routing.RoutingService">
<endpoint address="net.tcp://localhost:8009/proposalRouter"
binding="netTcpBinding"
contract="System.ServiceModel.Routing.IRequestReplyRouter"
name="proposalRouter" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceDebug includeExceptionDetailInFaults="true" />
<routing filterTableName="proposalRoutingTable" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding sendTimeout="00:45:00" maxReceivedMessageSize="2000000" />
</netTcpBinding>
</bindings>
<routing>
<filters>
<filter name="proposalFilter" filterType="EndpointAddress" filterData="proposalRouter"/>
</filters>
<filterTables>
<filterTable name="proposalRoutingTable">
<add filterName="proposalFilter" endpointName="defaultProposalService"/>
</filterTable>
</filterTables>
</routing>
<client>
<endpoint address="http://localhost:64434/ProposalService.svc"
binding="basicHttpBinding"
contract="*"
name="defaultProposalService"/>
</client>
给出的错误是:
无效的 URI:无法确定 URI 的格式。
我已将问题缩小到客户端 > 端点,但这是 svc 的 uri,不确定问题是什么
如果有人能告诉我我哪里出错了,我将不胜感激。
解决方案
您的配置文件中的过滤器是错误的。当filtertype的值为address时,filterdata应该是一个URI。
所以你的过滤器应该是这样的:
<filters>
<filter name="proposalFilter" filterType="EndpointAddress" filterData="net.tcp://localhost:8009/proposalRouter"/>
</filters>
有关 FilterData 属性的更多信息,请参考以下链接:
推荐阅读
- javascript - 函数仅适用于 setInterval
- php - 是否可以在 php 中使用正则表达式根据条件替换一个词(之前或之后)一个短语?
- mysql - 别名为会话的mysql表?
- awk - awk 命令 - 定义单词的大小
- gitpython - 使用 GitPython 下载特定版本
- c# - 带有 Swagger 的通用 ApiController 基类
- android - 为什么 popBackStack 不使用 FragmentStatePagerAdapter 恢复到上一个片段?
- php - 无法制作 JSON 多级 PHP
- gcc - 与系统库动态或静态链接的库的交叉编译
- r - 拆分单元格的内容并创建一个新列表