WCF:无法创建服务

时间:2014-04-29 01:34:45

标签: c# mysql wcf

我有一个无法建立数据库连接的WCF服务,因为我使用普通的Sql而不是mySQL。所以,我在我的代码中切换,现在运行时我得到“无法添加服务。可能无法访问服务元数据。请确保您的服务正在运行并公开元数据”错误。任何人都知道为什么会这样吗?在我进行切换之前,客户端运行正常,除了没有进行数据库连接。

这是我的网络配置文件:

<?xml version="1.0"?>
<configuration>
 <appSettings>
    <add key="ConnectString" value="server=xxx;database=xxx;uid=xxx;pwd="xxxx"/>
  </appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime/>
<pages controlRenderingCompatibilityVersion="4.0"/>
</system.web>
<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior>

      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<protocolMapping>
  <add binding="basicHttpsBinding" scheme="https"/>
 </protocolMapping>
 <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
 </system.serviceModel>
  <system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>

1 个答案:

答案 0 :(得分:1)

您可以通过为服务添加mex绑定来使您的元数据可以访问。

对于https访问

<endpoint
      address="mex"
      binding="mexHttpsBinding"
      contract="IMetadataExchange"
      bindingConfiguration=""
      name="MexHttpsBindingEndpoint"/>

用于Http访问

<endpoint
      address="mex"
      binding="mexHttpBinding"
      contract="IMetadataExchange"
      bindingConfiguration=""
      name="MexHttpBindingEndpoint"/>
相关问题