簡體   English   中英

無法為net.tcp WCF服務添加服務客戶端

[英]Unable to add service client for a net.tcp WCF service

我正在嘗試為基於net.tcp的WCF服務添加客戶端。 當我使用“添加服務參考”並提供以下URL: net.tcp://localhost/service1.svc時 ,出現以下錯誤。

無法識別URI前綴。 元數據包含無法解析的引用:“ net.tcp://localhost/service1.svc”。 無法連接到net.tcp://localhost/service1.svc。 連接嘗試持續時間為00:00:02.0051147。 TCP錯誤代碼10061:無法建立連接,因為目標計算機主動拒絕它127.0.0.1:808。 無法建立連接,因為目標計算機主動拒絕了該連接127.0.0.1:808如果在當前解決方案中定義了服務,請嘗試構建解決方案並再次添加服務引用。

我檢查了Windows組件中的WCF非HTTP服務,但是已經安裝了它們。 這很簡單:

為WCF服務啟用非HTTP協議

如您所見,它們是為.NET 3.5.1安裝的,而我的服務是在.NET 4.5中構建的。 這是問題嗎? 我應該如何解決呢? 因為Windows組件列表中沒有.NET 4.5的選項。

以下是我的WCF服務的配置:

<system.serviceModel>
<services>
<service name="CoreService.Service1" behaviorConfiguration="beh1">
  <host>
    <baseAddresses>
      <add baseAddress="net.tcp://localhost/Service1.svc"/>
    </baseAddresses>
  </host>
        <endpoint
     binding="netTcpBinding"
     bindingConfiguration="ultra"
     contract="CoreService.IAccountService"/>
       <endpoint
     binding="netTcpBinding"
     bindingConfiguration="ultra"
     contract="CoreService.ICategoryService"/>
         <endpoint
     binding="netTcpBinding"
     bindingConfiguration="ultra"
     contract="CoreService.ICommonService"/>
         <endpoint
     binding="netTcpBinding"
     bindingConfiguration="ultra"
     contract="CoreService.IFollowerService"/>
         <endpoint
     binding="netTcpBinding"
     bindingConfiguration="ultra"
     contract="CoreService.IInterestService"/>
<endpoint
     binding="netTcpBinding"
     bindingConfiguration="ultra"
     contract="CoreService.IInviteService"/>

  <endpoint
          address="mex"
          binding="mexTcpBinding"
          contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="ultra"
     maxBufferPoolSize="2147483647"
     maxBufferSize="2147483647"
     maxConnections="2147483647"
     maxReceivedMessageSize="2147483647"
     portSharingEnabled="false"
     transactionFlow="false"
     listenBacklog="2147483647"
     sendTimeout="00:01:00">
<security mode="None">
<message clientCredentialType="None"/>
<transport protectionLevel="None" clientCredentialType="None"/>
</security>
<reliableSession enabled="false"/>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
    <serviceBehaviors>
      <behavior name="beh1">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="True" />
        <dataContractSerializer maxItemsInObjectGraph="65536" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

WCF HTTP或非HTTP激活功能與您的服務之間似乎不存在兼容性問題。

據我說,IIS中缺少配置或配置錯誤,這可以解釋連接被拒絕的原因。 要使用net.tcp正確配置IIS,請在此處查看

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM