2011-04-29 118 views
1

我正在創建WCF服務。這是我的第一個。我收到錯誤:未找到WCF默認端點

Could not find default endpoint element that references contract 'WCFClient.IWCFClient' in the ServiceModel client configuration section.

我嘗試過切換端點名稱等,並刪除/重新創建服務引用。我似乎無法弄清楚問題所在。

應用配置:

<bindings> 
    <basicHttpBinding> 
     <binding name="BasicHttpBinding_IWCFClient" 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="" /> 
        <message clientCredentialType="UserName" algorithmSuite="Default" /> 
       </security> 
      </binding> 
    </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:4295/Services/WCFClient.svc" 
      binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWCFClient" 
      contract="WCFClient.IWCFClient" name="BasicHttpBinding_IWCFClient" /> 
    </client> 

服務配置:

<services> 
    <service behaviorConfiguration="WCFGraphicManagementTool.Services.WCFClientBehavior" 
    name="WCFGraphicManagementTool.Services.WCFClient"> 
     <endpoint address="" name="BasicHttpBinding_IWCFClient" binding="basicHttpBinding" contract="WCFGraphicManagementTool.Contracts.IWCFClient"> 
    </endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="WCFGraphicManagementTool.Services.WCFClientBehavior"> 
     <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
     <serviceThrottling maxConcurrentCalls="120" maxConcurrentSessions="120" maxConcurrentInstances="120" /> 
     <serviceMetadata httpGetEnabled="True" /> 
     <serviceDebug includeExceptionDetailInFaults="True" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors>  
+0

你如何創建客戶端代理? – 2011-04-29 13:26:22

+0

這是你的意思: – 2011-04-29 13:38:34

+0

WCFClient.WCFClientClient WCFClient = new WCFClient.WCFClientClient();這是它出錯的路線。 – 2011-04-29 13:38:51

回答

1

我想通了。我需要將它添加到項目的web.config中。它在服務中,但不在項目中。

0

這通常是由於在配置文件並且或者合同名上指定的服務名稱/命名空間之間的不匹配服務文件的源代碼或標記。通常在通過Visual Studio創建新服務之後發生,然後重命名服務/名稱空間。

在Solution Explorer中的.svc文件上單擊右鍵,選擇「查看標記」

檢查的「服務」屬性值是正確的。檢查名稱空間和名稱是否與您分配的名稱空間和名稱相匹配。

應該是這樣的:

<%@ ServiceHost Language="C#" Debug="true" Service="WCFGraphicManagementTool.Services.WCFClient" CodeBehind="WCFClient.svc.cs" %> 
相關問題