繁体   English   中英

WCF:无法找到端点引用

[英]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页面,这将解决问题。 对于微软没有对这些常见问题提供尽可能多的支持感到不满。

我有同样的问题,我找到了这个链接。

http://social.technet.microsoft.com/Forums/en-US/dea0763d-d6ea-4659-8ef0-8275514d066a/sp2010-consuming-web-service-in-visual-web-part?forum=sharepointdevelopmentprevious

我做到了,工作得很好。 问题是部署不会将服务模型配置从Visual Studio的app.config复制到IIS的web.config。

我希望有所帮助。

最好的祝福。

您的客户端端点似乎没有默认配置(name =“”或无名称)。 尝试使用:

WcfServiceReference1.Service1Client client = new WcfServiceReference1.Service1Client("BasicHttpBinding_IService1");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM