[英]WcfTestClient: Failed to add a service. Service metadata may not be accessible
at the beginning sorry for my English. 一开始对我的英语感到抱歉。
I know that there are already answers for this question but none of them worked for me. 我知道这个问题已经有了答案,但是没有一个对我有用。 I am trying to connect to my database.
我正在尝试连接到我的数据库。
I am working on: 我正在努力:
I have already checked Tools->Options->Project and Solutions->Web Projects->Use the 64 bit version of IIS Express for web sites and projects. 我已经检查了“工具”->“选项”->“项目和解决方案”->“ Web项目”->“将IIS Express的64位版本用于网站和项目”。
My code from View Markup (Service1.svc): <%@ ServiceHost Language="C#" Debug="true" Service="WCFconnection.Service1" CodeBehind="Service1.svc.cs" %> 我从视图标记(Service1.svc)中得到的代码: <%@ ServiceHost Language =“ C#” Debug =“ true” Service =“ WCFconnection.Service1” CodeBehind =“ Service1.svc.cs”%>
here is my Web.config 这是我的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>
When I go to website and put localhost:23233 into address I can see all the files, also my Service1.svc. 当我进入网站并将localhost:23233放入地址时,我可以看到所有文件,还有我的Service1.svc。 But if I try to make WcfTestClient I got error:
但是,如果我尝试使WcfTestClient出现错误:
Failed to add a service. 添加服务失败。 Service metadata may not be accessible.
服务元数据可能无法访问。 Make sure your service is running and exposing metadata.
确保您的服务正在运行并公开元数据。
Error: Cannot obtain Metadata from http://localhost:23233/ If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address... 错误:无法从http:// localhost:23233 /获取元数据。如果这是您有权访问的Windows(R)Communication Foundation服务,请检查是否已在指定地址启用元数据发布...
Please help me. 请帮我。
Based on the error that WcfTestClient is giving you, you are not providing the full endpoint url. 根据WcfTestClient给您的错误,您没有提供完整的端点URL。
You are adding http://localhost:23233/
您正在添加
http://localhost:23233/
You should be adding http://localhost:23233/Service1.svc
您应该添加
http://localhost:23233/Service1.svc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.