1

嗨,我正在研究具有 http + tcp 服务的 wcf,这是我的配置:

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
  <baseAddressPrefixFilters>
    <add prefix="http://localhost/API/"/>
  </baseAddressPrefixFilters>
</serviceHostingEnvironment>

<standardEndpoints>
  <webHttpEndpoint>
    <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
  </webHttpEndpoint>
</standardEndpoints>

<services>
  <service name="API.APIsrv" behaviorConfiguration="ServiceBehaviour">

    <endpoint address="http://localhost/tAPI/Basic" binding="basicHttpBinding" name="Basic" bindingConfiguration="Basic" contract="API.IAPIsrv" >
    </endpoint>

    <endpoint address="http://localhost/API" binding="webHttpBinding" name="APIsrv" contract="API.IAPIsrv" behaviorConfiguration="web">
    </endpoint>

    <endpoint address="net.tcp://localhost/API"  binding="netTcpBinding" name="APIsrv.netTcpBinding" contract="API.IAPIsrv">
    </endpoint>

    <endpoint address="http://localhost/API/mex"
      binding="mexHttpBinding"
      contract="IMetadataExchange" />

    <endpoint address="net.tcp://localhost/API/mex"
              binding="mexTcpBinding"
              contract="IMetadataExchange" />

  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehaviour">
      <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost/API/APIsrv.svc"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>

  <endpointBehaviors>
    <behavior name="web">
      <webHttp helpEnabled="true"/>
    </behavior>
  </endpointBehaviors>
</behaviors>

<bindings>

  <basicHttpBinding>
    <binding name="Basic" />
  </basicHttpBinding>
  <netTcpBinding>
    <binding name="APIsrv.netTcpBinding" transferMode="Streamed" maxReceivedMessageSize="20480000">
      <security mode="None"></security>
    </binding>
  </netTcpBinding>

</bindings>

在我的全局文件中,我处理路由地址:

protected void Application_Start(object sender, EventArgs e)
    {
        RouteTable.Routes.Add(new ServiceRoute("", new ServiceHostFactory(), typeof(APIsrv)));
    }

在我的本地客户端测试中,我收到此错误:由于编译期间出现异常,无法激活服务'/API/'。异常消息是: 'http://localhost/API/Basic' 的 ChannelDispatcher 与合同 '"IAPIsrv"' 无法打开其 IChannelListener。

我该如何解决这个问题

4

0 回答 0