找不到默认端点元素错误

时间:2013-12-05 05:44:50

标签: c# asp.net wcf dotnetnuke

我在使用WCF服务时遇到错误。我开发了一个由usercontrol使用的wcf服务。用户控件在DNN中用作模块。

但是,如果我只是在Web应用程序中使用wcf它工作正常但在DNN模块中消耗正在提供以下错误

  

无法在ServiceModel客户端配置部分中找到引用合同“OperationService.IOperation”的默认端点元素。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素。

请告知。

客户端配置在

之下
<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IOperation" />
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:54147/WCFService/Service.svc"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IOperation"
            contract="OperationService.IOperation" name="WSHttpBinding_IOperation">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

从评论中添加了wcf服务的服务配置

<system.serviceModel> 
  <services>
    <service behaviorConfiguration="ServiceBehavior" name="Operation"> 
      <endpoint address="" binding="wsHttpBinding" 
                contract="IOperation">
        <identity>
          <dns value="localhost"/> 
        </identity> 
      </endpoint>
      <endpoint address="mex" binding="mexHttpBinding" 
                contract="IMetadataExchange"/> 
    </service> 
  </services>
  <behaviors> 
    <serviceBehaviors>
      <behavior name="ServiceBehavior"> 
        <serviceMetadata httpGetEnabled="true"/> 
        <serviceDebug includeExceptionDetailInFaults="false"/> 
      </behavior>
    </serviceBehaviors> 
  </behaviors>
</system.serviceModel>

2 个答案:

答案 0 :(得分:1)

将app.config中的部分复制到您网站的web.config中。您可能需要更改端点的地址属性。

答案 1 :(得分:0)

合约名称需要在<endpoint>元素中完全限定(名称空间+名称),如下所示:

<endpoint address="" binding="wsHttpBinding" 
          contract="OperationService.IOperation">

另外,请确保<service>元素中的name属性与.svc文件标记中的name属性匹配。

相关问题