[英]WCF: Cannot find endpoint reference
我正在使用SharePoint 2013 webpart,並且webpart上的標簽需要使用WCF與SQL Server數據表進行通信。 我已經創建了WCF接口和主類,並且還在我的Visual webpart中調用了這樣的服務,如下所示:
protected void Page_Load(object sender, EventArgs e)
{
WcfServiceReference1.Service1Client client = new WcfServiceReference1.Service1Client();
CustomerNameLbl.Text = client.GetCustomerName(ProjectIDDescLbl.Text);
}
其中WcfServiceReference1是添加的WCF服務引用,並且正在根據項目編號標簽更改客戶標簽文本。 該項目構建和部署正常,但是當我添加webpart時,我收到此錯誤: 找不到引用ServiceModel客戶端配置部分中的合同'WcfServiceReference1.IService1'的默認端點元素。 這可能是因為沒有為您的應用程序找到配置文件,或者因為在客戶端元素中找不到與此合同匹配的端點元素。
我的app.config文件是這樣的:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://as-sv-dev02:2345/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="WcfServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
web.config文件(對於SharePoint)是這樣的:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://as-sv-dev02:2345/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="WcfServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
任何人都可以指導我如何解決這個問題? 我在某個地方出錯了嗎?
經過大量的研究,我發現SharePoint存在一些我不太懂的問題。 值得慶幸的是,及時,我選擇不使用SharePoint方式,而是使用簡單的.aspx頁面,這將解決問題。 對於微軟沒有對這些常見問題提供盡可能多的支持感到不滿。
我有同樣的問題,我找到了這個鏈接。
我做到了,工作得很好。 問題是部署不會將服務模型配置從Visual Studio的app.config復制到IIS的web.config。
我希望有所幫助。
最好的祝福。
您的客戶端端點似乎沒有默認配置(name =“”或無名稱)。 嘗試使用:
WcfServiceReference1.Service1Client client = new WcfServiceReference1.Service1Client("BasicHttpBinding_IService1");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.