WCF服务主机找不到任何服务元数据 [英] WCF service host cannot find any service metadata

查看:431
本文介绍了WCF服务主机找不到任何服务元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我几乎已经将vb中的ASMX中的服务迁移到了基于WCF 4.0的新版本,但是由于在启动时收到消息,所以我无法运行它:

I've almost migrated service in ASMX in vb to new WCF 4.0 based, but I can't run it because I get an message at start:

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有什么问题.

I don't know what's wrong with this 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>

推荐答案

您的WCF服务是一个库(DLL)吗?我问是因为您发布的配置文件中包含以下行:

Is your WCF service a library (DLL)? I ask because of the following line in the config file you posted:

< !!-部署服务库项目时,必须将配置文件的内容添加到主机的app.config文件.System.Configuration不支持库的配置文件.->

如果您的服务是DLL,则需要在主机的配置文件中发布< system.serviceModel> 部分.对于IIS,该文件为web.config文件;对于Windows服务或自托管服务,它将是app.config文件.如上面的注释行所述,服务库不使用它们自己的配置文件,而是使用主机的配置文件.

If your service is a DLL, then you'll need to post the <system.serviceModel> section in the host's config file. For IIS, that would be the web.config file; for a Windows Service or self-hosted service, it would be the app.config file. As the commented line above says, service libraries do not use their own config files, they utilize the host's config file.

这篇关于WCF服务主机找不到任何服务元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆