【问题标题】:WCF : Client > Endpoint > Error : Invalid URI on working URLWCF:客户端 > 端点 > 错误:工作 URL 上的 URI 无效
【发布时间】:2020-06-08 11:22:19
【问题描述】:

我正在设置 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,不确定问题是什么

如果有人能告诉我哪里出错了,我将不胜感激。

【问题讨论】:

    标签: c# .net wcf


    【解决方案1】:

    您的配置文件中的过滤器错误。当filtertype的值为address时,filterdata应该是一个URI。

    所以你的过滤器应该是这样的:

        <filters>
                <filter name="proposalFilter" filterType="EndpointAddress" filterData="net.tcp://localhost:8009/proposalRouter"/>
        </filters>
    

    关于FilterData属性的更多信息,请参考以下链接:

    https://docs.microsoft.com/en-us/dotnet/api/system.servicemodel.routing.configuration.filterelement.filterdata?view=netframework-4.8

    【讨论】:

      猜你喜欢
      • 2012-02-07
      • 2014-05-12
      • 2011-02-10
      • 1970-01-01
      • 2020-07-25
      • 1970-01-01
      • 2011-04-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多