簡體   English   中英

找不到默認端點元素錯誤

[英]Could not find default endpoint element error

使用WCF服務時出現錯誤提示。 我開發了一個wcf服務,該服務正在由usercontrol使用。用戶控件在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>

將部分從app.config復制到站點的web.config。 您可能需要更改端點的地址屬性。

合同名稱必須在<endpoint>元素中完全限定(名稱空間+名稱),如下所示:

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

另外,請確保<service>元素中的name屬性與.svc文件標記中的name屬性匹配。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM