【问题标题】:IMetadataExchange issue in WCFWCF 中的 IMetadataExchange 问题
【发布时间】:2011-04-16 20:48:30
【问题描述】:

我正在使用 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>

【问题讨论】:

    标签: c# .net wcf visual-studio-2010


    【解决方案1】:

    您能否提供一些有关您配置服务的方式的详细信息。

    http://msdn.microsoft.com/en-us/library/ms734765.aspx

    此链接有步骤。您应该对第 5 点和第 6 点感兴趣。

    帕万

    尝试将此添加到配置文件的行为中:

    <behaviors>
          <serviceBehaviors>
            <behavior name="CalculatorServiceBehavior">
              <serviceMetadata httpGetEnabled="True"/>
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
    

    并将服务元素更改为添加此行为:

    <service 
              name="Microsoft.ServiceModel.Samples.CalculatorService"
              behaviorConfiguration="CalculatorServiceBehavior">
    

    问候,

    帕万

    【讨论】:

    • 感谢劳特斯!您提供的链接是关于如何进行自托管。我正在做 IIS 托管。我已经在我的原始帖子中发布了我的 web.config,任何想法有什么问题吗?如果您需要任何进一步的信息进行分析,请告诉我。提前致谢!
    • 感谢劳特斯!格式看起来不太好。感谢您是否可以通过编辑您的帖子进行更新来在您的回复中发布您提议的 web.config?
    • 如果您阅读了同一篇 MSDN 文章的第 3 条评论,您会找到解决方案 :)
    • @rauts,我看了第三条评论但无法理解。您能否解释一下为什么它在与 msdn 相同时不起作用?
    猜你喜欢
    • 1970-01-01
    • 2011-02-04
    • 1970-01-01
    • 2012-02-17
    • 2021-11-21
    • 2012-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多