这是我使用MSDN网站上的教程编写ap WCF服务的第一步。
我做了什么:
现在我必须单击“确定”按钮下载服务信息。在这一点上,我收到一个错误(小心,我',使用德语Visual Studio,所以翻译可能与英文原版消息不符:
“错误:无法从地址获取元数据。确保地址正确”
如果我点击链接标签“详细信息”,我会收到以下信息:
**Error: Cannot obtain Metadata from "http://localhost:53948/AdventureWorksService.svc/_vti_bin/ListData.svc/$metadata".**
--
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
...
</html>
--.
Metadata contains a reference that cannot be resolved: "http://localhost:53948/AdventureWorksService.svc".
The contenttype "text/html" of the message doesn't match with the content type of the binding (application/soap+xml; charset=utf-8).
服务项目中没有App.config,而是Web.Config:
<?xml version="1.0" encoding="utf-8"?>
<!--
Weitere Informationen zum Konfigurieren der ASP.NET-Anwendung finden Sie unter
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<connectionStrings>
<add name="AdventureWorksLTEntities" connectionString="metadata=res://*/AdventureWorksModel.csdl|res://*/AdventureWorksModel.ssdl|res://*/AdventureWorksModel.msl;provider=System.Data.SqlClient;provider connection string="data source=MB-SQL2008;initial catalog=AdventureWorksLT;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</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>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
</configuration>
我想这与HTTP协议有关,而协议没有在服务中定义。
你能帮我做点什么吗?我希望,我已经发布了所有必要的信息。由于 迈克尔
答案 0 :(得分:0)
尝试在system.servicemodel标记
中添加这样的元数据<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors></behaviors>