在web.config中添加第三个端点,显示错误

时间:2018-06-03 05:40:57

标签: c# wcf wcf-data-services wcf-binding

我是第一次使用WCF服务,当我添加2个端点时,它工作正常,而在web.config中添加第三个端点则显示以下错误

以下是我在web.config中添加的服务

 <services>
      <service behaviorConfiguration="Default" name="WCFCurd.WCFContactService">
        <endpoint address="contact" binding="basicHttpBinding" contract="WCFCurd.IWCFContact" />
        <endpoint address="Calc" binding="basicHttpBinding" contract="WCFCurd.Ialc" />
        <endpoint address="addition" binding="basicHttpBinding" contract="WCFCurd.Addition" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <!--<baseAddresses>
            <add baseAddress="http://localhost:4072/WCFCurd"/>
          </baseAddresses>-->
        </host>
      </service>
    </services>

显示的错误是

  

错误:无法从中获取元数据   http://localhost:4072/WCFContactService.svc如果这是Windows(R)   请访问您的Communication Foundation服务   检查您是否已在指定的位置启用元数据发布   地址。有关启用元数据发布的帮助,请参阅   MSDN文档在   http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata交流   错误URI:http://localhost:4072/WCFContactService.svc元数据   包含无法解析的引用:   &#39; http://localhost:4072/WCFContactService.svc&#39 ;.没有端点   听http://localhost:4072/WCFContactService.svc那可能   接受消息。这通常是由不正确的地址或   SOAP动作。有关更多详细信息,请参阅InnerException(如果存在)。该   远程服务器返回错误:(404)Not Found.HTTP GET错误URI:   http://localhost:4072/WCFContactService.svc发生错误   下载&#39; http://localhost:4072/WCFContactService.svc&#39;。请求   失败并显示错误消息: - 服务

     

该服务遇到错误。

     

ExceptionDetail,可能由。创建   IncludeExceptionDetailInFaults = true,其值   是:System.InvalidOperationException:在调用中抛出异常   到WSDL导出扩展:   System.ServiceModel.Description.DataContractSerializerOperationBehavior

当WCFContactService.scv运行时它不会,这表示在添加第三个端点时出现上述错误

enter image description here

1 个答案:

答案 0 :(得分:2)

您可以理解的以下示例将对您有所帮助,请尝试使用此示例

            public int SimpleExample(<interface> Example1)
            {
                return Example1.ID;
            }

            public int SimpleExample1(<interface> Example2)
            {
                return Example2.ID;
            }

            public int SimpleExample2(<interface> Example3)
            {
                return Example3.ID;
            }

            public int SimpleExample3(<interface> Example4)
            {
                return Example4.ID;
            }

            public int SimpleExample4(<interface> Example5)
            {
                return Example5.ID;
            }

            public int SimpleExample5(<interface> Example6)
            {
                return Example6.ID;
            }
            .......

            public int SimpleExampleN(<interface> ExampleN)
            {
                return ExampleN.ID;
            }

我在web.config中找不到上述代码中的任何错误。这可能是由于函数名称或任何接口名称的冲突而发生的。

相关问题