2011-03-07 25 views
0

我收到以下錯誤WCF配置netTCp,終點是空

「上 ChannelFactory.Endpoint地址屬性爲空。該 的ChannelFactory的終結點必須指定 有效的地址。」

我不知道我在做什麼錯。有沒有人知道它的共鳴是什麼?下面是我的項目的App.config中服務器和客戶端 感謝您的幫助,對於

<system.serviceModel> 
    <services> 
     <service name="Server.DualService" behaviorConfiguration="NetTcpBehavior"> 
     <endpoint address="" 
       binding="netTcpBinding" 
       bindingConfiguration="DuplexBinding" 
       contract="Server.IDualService" /> 

     <endpoint address="mex" binding="mexTcpBinding" contract="Server.IDualService" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="net.tcp://localhost:8731/Service/DualService/" /> 
      </baseAddresses> 
     </host> 
     </service> 
     <service name="Server.PhoneService" behaviorConfiguration="Server.PhoneServiceBehavior"> 
     <endpoint address="" binding="wsHttpBinding" bindingConfiguration="" contract="Server.IPhoneService" /> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:4444/Service/PhoneService" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="Server.DualServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
     <behavior name="Server.PhoneServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
     <behavior name="NetTcpBehavior"> 
      <serviceThrottling maxConcurrentSessions="10000" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <netTcpBinding> 
     <binding name="DuplexBinding" sendTimeout="00:00:11"> 
      <reliableSession enabled="true" /> 
      <security mode="None" /> 
     </binding> 
     </netTcpBinding> 
    </bindings> 
    </system.serviceModel> 

客戶端

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="DefaultBinding_IPhoneService" closeTimeout="00:01:00" 
       openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
       allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
       messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
       useDefaultWebProxy="true"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
        maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
       <security mode="None"> 
        <transport clientCredentialType="None" proxyCredentialType="None" 
         realm=""> 
         <extendedProtectionPolicy policyEnforcement="Never" /> 
        </transport> 
        <message clientCredentialType="UserName" algorithmSuite="Default" /> 
       </security> 
      </binding> 
      <binding name="DefaultBinding_IDualService" closeTimeout="00:01:00" 
       openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
       allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
       messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
       useDefaultWebProxy="true"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
        maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
       <security mode="None"> 
        <transport clientCredentialType="None" proxyCredentialType="None" 
         realm=""> 
         <extendedProtectionPolicy policyEnforcement="Never" /> 
        </transport> 
        <message clientCredentialType="UserName" algorithmSuite="Default" /> 
       </security> 
      </binding> 
     </basicHttpBinding> 
     <wsHttpBinding> 
      <binding name="WSHttpBinding_IPhoneService" closeTimeout="00:01:00" 
       openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
       bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
       messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
       allowCookies="false"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
        maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
       <reliableSession ordered="true" inactivityTimeout="00:10:00" 
        enabled="false" /> 
       <security mode="Message"> 
        <transport clientCredentialType="Windows" proxyCredentialType="None" 
         realm=""> 
         <extendedProtectionPolicy policyEnforcement="Never" /> 
        </transport> 
        <message clientCredentialType="Windows" negotiateServiceCredential="true" 
         algorithmSuite="Default" establishSecurityContext="true" /> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint binding="basicHttpBinding" bindingConfiguration="DefaultBinding_IPhoneService" 
      contract="IPhoneService" name="DefaultBinding_IPhoneService_IPhoneService" /> 
     <endpoint binding="basicHttpBinding" bindingConfiguration="DefaultBinding_IDualService" 
      contract="IDualService" name="DefaultBinding_IDualService_IDualService" /> 
     <endpoint address="http://localhost:4444/Service/PhoneService" 
      binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IPhoneService" 
      contract="ServiceReference2.IPhoneService" name="WSHttpBinding_IPhoneService"> 
      <identity> 
       <userPrincipalName value="PANDZIA-PC\PANDZIA" /> 
      </identity> 
     </endpoint> 
    </client> 
</system.serviceModel> 

回答

1

有一些問題,你的配置。服務器通過net.tcp指定DualService,但客戶端使用BasicHttpBinding並且不指定地址。此外,您的客戶端已配置更多端點,然後您的服務公開,DualService中的mex端點具有不正確的合同(應爲IMetadataExchange)。

只有PhoneService的客戶端端點看起來正確。

+0

一切正常,你是對的:),再次感謝你,下面我把我的正確的配置,也許這​​將幫助別人,有一天。 。:D:D – user648518 2011-03-07 21:07:46

1

一切正常,你是對的:),再次感謝你,以下我把正確的配置,說不定哪天這將有助於給別人..:d:d

在服務器端我已經修正IMetadataExchange接口在端點:

<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" /> 

,我小有一點改變

<behavior name="NetTcpBehavior"> 
     <serviceMetadata/> 
     <serviceThrottling maxConcurrentSessions="10000" /> 
    </behavior> 

在客戶端刪除我在最看的旋轉代碼genereted與DualService並添加

<endpoint name="" 
       address="net.tcp://localhost:8731/Service/DualService/" 
       binding="netTcpBinding" 
       bindingConfiguration="DuplexBinding" 
       contract="IDualService" /> 

出綁定的樣子:

<netTcpBinding> 
     <binding name="DuplexBinding" sendTimeout="00:00:05" > 
      <reliableSession enabled="true" /> 
      <security mode="None" /> 
     </binding> 
     </netTcpBinding>