2015-01-08 68 views
3

我有WCF和net.tcp綁定的常見問題。 我看到所有帖子在stackoverflow也googling ..在WCF中添加服務引用時找不到net.tcp端點?

我不能添加服務引用到我的客戶端的主要問題。 我得到錯誤:

Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http]. 
  1. 我使用的是IIS 7,我檢查非HTTP.I添加到網站中啓用協議的net.tcp,還增加了對的net.tcp綁定。如果我點擊瀏覽(http)我的地址。我看到我的WCF應用程序文件夾,如果我選擇SVC文件我看到正常地址:

    svcutil.exe的的net.tcp://MYADDRESS/Service.svc/mex

我想我如果我看到這個URL,請正確設置我的IIS!

但是,當我嘗試添加引用到客戶端時,問題就開始了。只有我看到http端點和沒有net.tcp。

這是我的服務配置:

<?xml version="1.0"?> 
<configuration> 

     <appSettings> 
     <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
     </appSettings> 
     <system.web> 
     <compilation debug="true" targetFramework="4.5" /> 
     <httpRuntime targetFramework="4.5"/> 
     </system.web> 
     <system.serviceModel> 
     <services> 
      <service name="MYSERVICE.SERVICE" behaviorConfiguration="behavior1"> 
      <endpoint 
         binding="netTcpBinding" 
         contract="MYSERVICE.ISERVICE"> 
       <identity> 
       <dns value="localhost" /> 
       </identity> 
      </endpoint> 
      <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" /> 
      <host> 
       <baseAddresses> 
       <add baseAddress="net.tcp://localhost:60745/MYSERVICE/SERVICE/"/> 
       </baseAddresses> 
      </host> 
      </service> 
     </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="behavior1"> 
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false"/> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <protocolMapping> 
     <add binding="netTcpBinding" scheme="net.tcp" /> 
    </protocolMapping>  
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    <directoryBrowse enabled="true"/> 
    </system.webServer> 

</configuration> 

注:我的網站從60745個地址開始,但在的net.tcp綁定IIS我加60746:* 我也開入站出站規則,兩個端口。

謝謝!

+1

您的IIS服務器上的Windows功能中是否啓用了「Windows Communication Foundation非HTTP激活」功能? –

+0

是的。我啓用它。 – user1711993

+1

如果您的程序是.NET 4.5,您是否已經在.NET Framework 4.5高級服務中啓用了TCP激活(如果您的操作系統正在運行IIS) –

回答

3

從你在評論中提到的問題,我已經運行它,我自己也爲添加服務引用gui不處理mexTcpBinding很好。

您可以使用HTTP mex作爲元數據,並仍然使用net.tcp作爲數據通道。下面是我的一個使用http mex使用tcp通道的項目的例子。

<system.serviceModel> 
    <bindings> 
     <netTcpBinding> 
     <binding name="NetTcpConfig" closeTimeout="00:30:00" openTimeout="00:30:00" receiveTimeout="00:30:00" sendTimeout="00:30:00" transferMode="Streamed" 
      maxReceivedMessageSize="67108864"> 
      <security mode="Transport"> 
      <transport clientCredentialType="None"/> 
      </security> 
     </binding> 
     </netTcpBinding> 
    </bindings> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="AsyncStreaming"> 
      <dispatcherSynchronization asynchronousSendEnabled="true"/> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name=""> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
      <serviceCredentials> 
      <serviceCertificate findValue="Example" x509FindType="FindBySubjectName"/> 
      </serviceCredentials> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service name="Server.Endpoints.ExampleEndpoint"> 
     <endpoint address="" behaviorConfiguration="AsyncStreaming" binding="netTcpBinding" bindingConfiguration="NetTcpConfig" contract="Server.IExample"/> 
     <endpoint address="" behaviorConfiguration="AsyncStreaming" binding="netTcpBinding" bindingConfiguration="NetTcpConfig" contract="Server.IExample2"/> 
     <endpoint address="" behaviorConfiguration="AsyncStreaming" binding="netTcpBinding" bindingConfiguration="NetTcpConfig" contract="Server.IExample3"/> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
     </service> 
    </services> 
    <protocolMapping> 
     <add binding="netTcpBinding" scheme="net.tcp" bindingConfiguration="NetTcpConfig"/> 
    </protocolMapping>  
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/> 
    <diagnostics wmiProviderEnabled="false"> 
     <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" 
     maxMessagesToLog="3000"/> 
    </diagnostics> 
    </system.serviceModel> 
相關問題