wcf无法添加服务。服务元数据可能无法访问

时间:2014-01-21 12:38:33

标签: wcf nettcpbinding

我是wcf.i的新手,有简单的wcf服务,用于添加,减法,多重,分区等计算器。我的服务配置文件中有两个端点。一个是basicHttpBinding,另一个是netTcpBinding。当我点击f5然后wcf测试客户端出现并显示错误 wcf无法添加服务。服务元数据可能无法访问但如果我关闭netTcpBinding和mex for netTcpBinding并按f5,那么wcf测试客户端可以调用该服务。这是我的配置条目。所以,请看看,告诉我为什么我收到netTcpBinding错误以及如何解决它。

<?xml version="1.0"?>
<!--Copyright (c) Microsoft Corporation.  All Rights Reserved.-->
<configuration>
    <system.serviceModel>
        <services>
            <service name="MyTcpActivation.CalculatorService" behaviorConfiguration="CalculatorServiceBehavior">

                <endpoint address="" binding="netTcpBinding" bindingConfiguration="PortSharingBinding" 
                contract="MyTcpActivation.ICalculator"/>

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




                <endpoint address="" binding="basicHttpBinding" contract="MyTcpActivation.ICalculator" />
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>             
            </service>
        </services>
        <bindings>
            <netTcpBinding>
                <binding name="" portSharingEnabled="true">
                    <security mode="None"/>
                </binding>
            </netTcpBinding>
        </bindings>
        <!--For debugging purposes set the includeExceptionDetailInFaults attribute to true-->
        <behaviors>
            <serviceBehaviors>
                <behavior name="CalculatorServiceBehavior">
                    <serviceMetadata httpGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
    <system.web>
        <compilation debug="true"/></system.web></configuration>

请指导我在配置文件中修复的位置,因此不应该出现我使用的任何绑定问题。感谢

1 个答案:

答案 0 :(得分:0)

我认为......如果你有两个“IMetadataExchange”端点,那么你需要提供不同的地址。例如:

        <service name="MyTcpActivation.CalculatorService" behaviorConfiguration="CalculatorServiceBehavior">

            <endpoint address="" binding="netTcpBinding" bindingConfiguration="PortSharingBinding" contract="MyTcpActivation.ICalculator"/>
            <endpoint address="mex1" binding="mexTcpBinding" contract="IMetadataExchange"/>

            <endpoint address="" binding="basicHttpBinding" contract="MyTcpActivation.ICalculator" />
            <endpoint address="mex2" binding="mexHttpBinding" contract="IMetadataExchange"/>             
        </service>