代码之家  ›  专栏  ›  技术社区  ›  Program.X

WCF元数据不工作

wcf
  •  5
  • Program.X  · 技术社区  · 17 年前

    我已经多次尝试让我的WCF服务公开元数据。相反,我一直保留例外:

    在列表中找不到 该处执行的合同 证券经纪人 . 将ServiceMetadataBehavior添加到 配置文件或将其复制到 ServiceHost直接启用支持 为了这份合同。

    ... 使用IE手动浏览服务时。

    但我的web.config看起来还不错:

    <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <behaviors>
        <endpointBehaviors>
            <behavior name="webHttpEnablingBehaviour">
                <webHttp />
            </behavior>
        </endpointBehaviors>
        <serviceBehaviors>
            <behavior name="webHttpEnablingBehaviour">
                <serviceMetadata httpGetEnabled="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service name="IWW.MIGTurbo2.WCF.Security.SecurityBroker">
            <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
            <endpoint address=""
                binding="webHttpBinding"
                bindingConfiguration="default"
                contract="IWW.MIGTurbo2.WCF.Security.ISecurityBroker"
                    behaviorConfiguration="webHttpEnablingBehaviour">
            </endpoint>
        </service>
    </services>
    <client />
    <bindings>
        <webHttpBinding>
            <binding name="default" />
        </webHttpBinding>
    </bindings>
    </system.serviceModel>
    

    二甲胺交换 墨西哥 很好,就我所见,已经连接好了。我错过了什么愚蠢的事吗?

    编辑

    我的服务定义如下所示(如果有用):

    <%@ ServiceHost Language="C#" Debug="true" Service="IWW.MIGTurbo2.WCF.Security.SecurityBroker" Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory"   %>
    
    2 回复  |  直到 17 年前
        1
  •  9
  •   Brian    17 年前

    配置文件在“endpoint”元素上具有behaviorConfiguration属性,但在“service”元素上也需要它。

        2
  •  2
  •   GrandMasterFlush    10 年前

    我正在为所有人使用NetTcpBinding。在我的案例中,我遇到了同样的问题,并通过添加以下内容来解决:

    (a) 连接到mex端点的behaviorConfiguration=“”

      <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" behaviourConfiguration="" />
    

      <services>
         <service name="AcmeService" behaviorConfiguration="mex">
    

    (c) 行为条目

      <behaviors>
        <serviceBehaviors>
            <behaviour name="mex">
                <serviceDebug includeExceptionDetailInFaults="false"/>
                <serviceMetadata />
            </behavior>
         </serviceBehaviors>
      </behaviors>
    
    推荐文章