WCF调用抛出:“提供的URI方案'http'无效;期望'net.tcp'。”例外

时间:2009-09-24 21:01:04

标签: wcf wcf-client

我在IIS7中托管了一个WCF服务。

这是我在IIS中托管的服务的app.config

<system.serviceModel>
  <bindings />
  <services>
    <service behaviorConfiguration="querierSearch.Querier.WCF.QuerierBehavior"
      name="querierSearch.Querier.WCF.Querier">
      <endpoint 
         address="net.tcp://localhost:808/querierSearch.Querier.WCF/Querier.svc"
        binding="netTcpBinding" bindingConfiguration="" name="EndPointTCP"
        contract="querierSearch.Querier.WCF.IQuerier" />
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="querierSearch.Querier.WCF.QuerierBehavior">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

以下是客户端中引用WCF服务的app.config。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="EndPointTCP" closeTimeout="00:01:00" 
          openTimeout="00:01:00"
          receiveTimeout="00:10:00" sendTimeout="00:01:00" 
          transactionFlow="false" transferMode="Buffered" 
          transactionProtocol="OleTransactions"
          hostNameComparisonMode="StrongWildcard" listenBacklog="10" 
          maxBufferPoolSize="524288"
          maxBufferSize="65536" maxConnections="10" 
          maxReceivedMessageSize="65536">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" 
          axArrayLength="16384" maxBytesPerRead="4096" 
          maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="Transport">
            <transport clientCredentialType="Windows" 
            protectionLevel="EncryptAndSign" />
            <message clientCredentialType="Windows" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <client>
      <endpoint address="net.tcp://localhost/Search.Querier.WCF/Querier.svc"
        binding="netTcpBinding" bindingConfiguration="EndPointTCP"
        contract="SearchQueryService.IQuerier"
        name="EndPointTCP">
        <identity>
          <userPrincipalName value="joeuser@company.com" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
</configuration>

出于某种原因,我仍然得到“提供的URI方案'http'无效;期望'net.tcp'。”例外。

我无法弄清楚为什么......

3 个答案:

答案 0 :(得分:2)

实际上事实证明我错过了mex端点...... woops

答案 1 :(得分:0)

可能是这个

<serviceMetadata httpGetEnabled="true" />

您要求它在TCP服务上启用HTTP,这似乎可能会导致一些问题。

答案 2 :(得分:0)

我的问题是,在刷新behaviorConfiguration后,web.config中的Service References删除

(我的behaviorConfiguration使用clientVia地址而不是标准端点地址来允许它遍历防火墙。