2011-10-07 137 views
1

我幾乎在VB遷移服務ASMX基於新的WCF 4.0,但我不能運行它,因爲我在開始時得到一個消息:WCF服務主機無法找到任何服務元數據

WCF Service Host cannot find any service metadata. This may cause the client application to run improperly. Please check if metadate is enabled. Do you want to exit? 

我不知道這個app.config有什麼問題。

你可以看看它並幫助我嗎?

WCF Service Host cannot find any service metadata. This may cause the client application to run improperly. Please check if metadate is enabled. Do you want to exit? 

<?xml version="1.0"?> 
<configuration> 
    <configSections> 
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
     <section name="ExtraWS.My.MySettings" requirePermission="false" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 
    </sectionGroup> 
    </configSections> 
    <!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="ExtraWS.ExtraBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service behaviorConfiguration="ExtraWS.ExtraBehavior" name="ExtraWS.Service1"> 
     <endpoint address="" binding="basicHttpBinding" contract="ExtraWS.Service1" name ="mex"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <bindings> 
     <basicHttpBinding> 
     <binding allowCookies="false" bypassProxyOnLocal="false" closeTimeout="00:01:00" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" name="PostcodeLookupSoap" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> 
      <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="32" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" /> 
      <security mode="Transport"> 
      <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> 
      <message algorithmSuite="Default" clientCredentialType="UserName" /> 
      </security> 
     </binding> 
     <binding allowCookies="false" bypassProxyOnLocal="false" closeTimeout="00:01:00" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" name="C1WSSoap" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> 
      <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="32" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" /> 
      <security mode="Transport"> 
      <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> 
      <message algorithmSuite="Default" clientCredentialType="UserName" /> 
      </security> 
     </binding> 
     <binding allowCookies="false" bypassProxyOnLocal="false" closeTimeout="00:01:00" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" name="E1Soap" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> 
      <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="32" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" /> 
      <security mode="Transport"> 
      <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> 
      <message algorithmSuite="Default" clientCredentialType="UserName" /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="https://postcodews.mycompany.co.uk/PostcodeLookup.asmx" binding="basicHttpBinding" bindingConfiguration="PostcodeLookupSoap" contract="PostcodeService.PostcodeLookupSoap" name="PostcodeLookupSoap" /> 
     <endpoint address="https://C1.mycompany.co.uk/C1ws.asmx" binding="basicHttpBinding" bindingConfiguration="C1WSSoap" contract="C1Service.C1WSSoap" name="C1WSSoap" /> 
     <endpoint address="https://E1uat.mycompany.co.uk/qbitE1.asmx" binding="basicHttpBinding" bindingConfiguration="E1Soap" contract="E1Service.E1Soap" name="E1Soap" /> 
    </client> 
    </system.serviceModel> 
    <system.web> 
    <authorization> 
     <allow users="*" /> 
    </authorization> 
    <compilation debug="true" /> 
    <authentication mode="Windows" /> 
    <httpHandlers> 
     <remove path="*.asmx" verb="*" /> 
     <add path="*.asmx" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" verb="*" /> 
     <add path="*_AppService.axd" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" verb="*" /> 
     <add path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" verb="GET,HEAD" /> 
    </httpHandlers> 
    <httpModules> 
     <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    </httpModules> 
    <membership defaultProvider="ClientAuthenticationMembershipProvider"> 
     <providers> 
     <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" /> 
     </providers> 
    </membership> 
    <roleManager defaultProvider="ClientRoleProvider" enabled="true"> 
     <providers> 
     <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" /> 
     </providers> 
    </roleManager> 
    </system.web> 
    <applicationSettings> 
    <ExtraWS.My.MySettings> 
     <setting name="AlwaysAuthenticate" serializeAs="String"> 
     <value>False</value> 
     </setting> 
    </ExtraWS.My.MySettings> 
    </applicationSettings> 
    <appSettings> 
    SECRET/> 
    <add key="ClientSettingsProvider.ServiceUri" value="" /> 
    </appSettings> 
    <connectionStrings> 
    SECRET/> 
    </connectionStrings> 
    <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" /> 
    </startup> 
</configuration> 

回答

6

WCF服務是庫(DLL)嗎?我問,因爲在配置文件中的以下行你貼的:

<!-- When deploying the service library project, the content of the config file must be added to the host's app.config file. System.Configuration does not support config files for libraries. -->

如果你的服務是一個DLL,那麼你就需要發佈在主機的配置文件中<system.serviceModel>部分。對於IIS,這將是web.config文件;對於Windows服務或自託管服務,它將是app.config文件。正如上面的註釋行所述,服務庫不使用自己的配置文件,而是使用主機的配置文件。

+0

偉大的通知蒂姆。目前我還沒有訪問代碼,但在週一我會檢查它。謝謝:) – user278618

+0

還有什麼運氣呢? – Tim

+0

問題出在DataContract屬性上,或者由於缺少它們而致。我想出了這個感謝wcf追蹤。 – user278618

4

得到了解決方案!

此問題與服務名稱屬性有關。它無法在標籤中找到IService。我已將IService更改爲某個不同的名稱。需要映射正確的名稱。

+1

碰到類似的問題。請記住「服務名稱」將區分大小寫!當我的服務類中的名稱空間更改爲全部大寫時,我的工作服務中斷。浪費了幾個小時來追蹤它。 – kenchilada

+0

是的,有同樣的問題 - 注意到服務名稱是波浪線 - 通過解決方案資源管理器重命名服務類名稱沒有在App.Config文件中重命名... – Prokurors

1

在Solution Explorer中右鍵單擊app.config 1.這將打開配置對話框。 2.展開服務。 3.選擇終點。 4.在合同的右側點擊 5.這將打開應用程序目錄 6.打開bin文件夾。雙擊dll然後選擇 服務 7.點擊文件菜單並保存。

這裏hostissue是命名空間..因此服務名稱應該是hostissue.the類您的實施。

構建應用程序並運行它。