C# 演练中的元数据错误:将WPF控件绑定到WCF数据服务
像这样 因为元数据,我不能继续了。 这对我仍然不起作用。我更改了本地主机号码C# 演练中的元数据错误:将WPF控件绑定到WCF数据服务,c#,wpf,wcf,C#,Wpf,Wcf,像这样 因为元数据,我不能继续了。 这对我仍然不起作用。我更改了本地主机号码 address="http://localhost:54786/AdventureWorksService/mex" 剩下的我就这样离开了,但它不起作用。。。在APP.CONFIG或WEB.CONFIG中尝试过它。。。我甚至尝试添加… 我仍然得到元数据错误。如果可能,请帮助我提供详细的解决方案 这是web.config 这是app.config 问题中缺少一些信息,但我会猜一猜 您不公开元数据,这反过来会阻止您添
address="http://localhost:54786/AdventureWorksService/mex"
剩下的我就这样离开了,但它不起作用。。。在APP.CONFIG或WEB.CONFIG中尝试过它。。。我甚至尝试添加…
我仍然得到元数据错误。如果可能,请帮助我提供详细的解决方案
这是web.config
这是app.config
问题中缺少一些信息,但我会猜一猜 您不公开元数据,这反过来会阻止您添加服务引用。双重检查是否在承载服务的应用程序的配置(
web.config
)中有httpGetEnabled=“true”
。如果使用的是HTTPS
,则使用httpsGetEnabled=“true”
切换元素。如果需要,您可以将两者结合起来
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
尝试添加此配置并编辑相应的属性,然后在web浏览器中打开该服务。当您通过Visual Studio中的
添加服务引用添加服务时,客户端应自动更新app.config
。请发布您的.xml文件。同时检查您是否应用了任何安全设置。我发布了配置:)@Johnny:您在web.config
中缺少该服务的定义我是WCF和XAML的一个彻头彻尾的noob。。。所以请告诉我我到底错过了什么!?你能做一下演练,看看是否达到了同样的目的吗?我花了5分钟才喝到这一品脱。然后输入Web.config的完整XML,并输入您所指的项目。。。因为我不知道在哪里插入最后一个配置代码段应该在服务器(或具有wcf服务的项目)的web.config中。添加服务引用时,客户端配置将相应更新。
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<!--<system.serviceModel>-->
<services>
<service name="AdventureWorksService"
behaviorConfiguration="metadataSupport">
<endpoint
address="http://localhost:54786/AdventureWorksService/mex"
binding="mexHttpBinding"
contract="IMetadataExchange"
/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metadataSupport">
<serviceMetadata/>
</behavior>
</serviceBehaviors>
</behaviors>
<!--</system.serviceModel>-->
</configuration>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<system.serviceModel>
<services>
<service
name="MyApp.Services.MyService"
behaviorConfiguration="MyServiceBehavior">
<endpoint address=""
binding="wsHttpBinding"
contract="MyApp.Services.IMyService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" /> <!-- Set this to true to return exception details to the calling client. -->
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>