一开始抱歉我的英语。
我知道这个问题已经有答案,但它们都没有对我有用。 我正在尝试连接到我的数据库。
我正在努力:
我已经检查了工具 - >选项 - >项目和解决方案 - >网络项目 - >使用64位版本的IIS Express进行网站和项目。
来自View Markup(Service1.svc)的代码: <%@ ServiceHost Language =“C#”Debug =“true”Service =“WCFconnection.Service1”CodeBehind =“Service1.svc.cs”%>
这是我的Web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=XXXXXXXXXXXX" requirePermission="false" />
</configSections>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>
</system.web>
<system.serviceModel>
<services>
<service name="WCFconnection.Service1"
behaviorConfiguration="metadataBehavior">
<endpoint address="" binding="basicHttpBinding" contract="WCFconnection.IService1" />
<endpoint address="basic" binding="basicHttpBinding" contract="WCFconnection.IService1" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="localhost:23233/Service1.svc"
binding="basicHttpBinding"
contract="WCFconnection.IService1"
/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
<behavior name="DefaultBehavior">
<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">
<remove name="ApplicationInsightsWebTracking" />
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>
<directoryBrowse enabled="true" />
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
<connectionStrings>
<add name="ZPIEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=XXXXXX-XXXXXX;initial catalog=XXXXXX;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="ConStr" connectionString="Data Source=XXXXXXX-XXXXXXXX\XXXXXXX;Initial Catalog=XXXXXXX;Integrated Security=True"/>
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
当我访问网站并将localhost:23233放入地址时,我可以看到所有文件,也可以看到我的Service1.svc。但是,如果我尝试制作WcfTestClient,我会收到错误:
无法添加服务。可能无法访问服务元数据。确保您的服务正在运行并公开元数据。
错误:无法从http://localhost:23233/获取元数据如果这是您有权访问的Windows(R)Communication Foundation服务,请检查您是否已在指定地址启用元数据发布... < / em>的
请帮帮我。
答案 0 :(得分:0)
根据WcfTestClient提供给您的错误,您没有提供完整的端点网址。
您正在添加func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = tableView.cellForRowAtIndexPath(indexPath)
let color = getRandomColor()
cell.backgroundColor = color
cell.contentView.backgroundColor = color
}
您应该添加http://localhost:23233/