我正在使用VSTS 2010 + C#+。Net 4.0 + IIS 7.5 + Windows 7.我在此处关注MSDN示例,未作任何修改,http://msdn.microsoft.com/en-us/library/ms733766.aspx
当我在IIS中打开service.svc文件(在IIS管理器中,右键单击svc文件并选择浏览)时,会出现这样的错误,任何想法有什么问题?
服务列表中的CalculatorService找不到协议名称“IMetadataExchange”。将ServiceMetadataBehavior添加到配置文件或直接添加到ServiceHost
这是我正在使用的web.config,
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<!-- This section is optional with the default configuration
model introduced in .NET Framework 4 -->
<service name="Microsoft.ServiceModel.Samples.CalculatorService">
<!-- This endpoint is exposed at the base address provided by host: http://localhost/servicemodelsamples/service.svc -->
<endpoint address=""
binding="wsHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
<!-- The mex endpoint is exposed at http://localhost/servicemodelsamples/service.svc/mex -->
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
</configuration>
答案 0 :(得分:5)
您能否详细介绍一下您配置服务的方式。
http://msdn.microsoft.com/en-us/library/ms734765.aspx
此链接包含以下步骤。第5点和第6点应该是您感兴趣的。
帕
尝试将此添加到Config文件的行为:
<behaviors>
<serviceBehaviors>
<behavior name="CalculatorServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
并将service元素更改为ADD此行为:
<service
name="Microsoft.ServiceModel.Samples.CalculatorService"
behaviorConfiguration="CalculatorServiceBehavior">
的问候,
PAVAN