WCF调用抛出:“所提供的URI方案‘HTTP’是无效的;预期“的net.tcp”。”异常

StackOverflow https://stackoverflow.com/questions/1474134

  •  16-09-2019
  •  | 
  •  

我在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>

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

<?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’”。异常。

我无法找出为什么.....

有帮助吗?

解决方案

其实原来我是缺少MEX终结点... woops

其他提示

可能这

<serviceMetadata httpGetEnabled="true" />

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

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

(我的behaviorConfiguration使用clientVia地址而不是一个标准的端点地址,以允许它穿越防火墙)。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top