2011-10-07 171 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类您的实施。

构建应用程序并运行它。

相关问题