2

I have asked this on the general StackOverflow website as well, but would like some opinions specific to SharePoint.

I am working on a SharePoint 2013 webpart and a label on the webpart needs to communicate with a SQL Server data table using WCF. I have created the WCF interface and main class, and have also invoked the service in my Visual webpart like this:

protected void Page_Load(object sender, EventArgs e)
    {
        WcfServiceReference1.Service1Client client = new WcfServiceReference1.Service1Client();
        CustomerNameLbl.Text = client.GetCustomerName(ProjectIDDescLbl.Text);
    }

Where WcfServiceReference1 is the added WCF service reference and a customer label text is being changed depending on the project number label.

The project builds and deploys fine but when I add the webpart, I get this error: Could not find default endpoint element that references contract 'WcfServiceReference1.IService1' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

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 file (for 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>

Can anyone guide me on how to resolve this? Am I going wrong somewhere?

  • Where did you deploy the .svc to? Can you test by hitting http://as-sv-dev02:2345/Service1.svc in a browser? – Kit Menke Sep 3 '13 at 17:20
  • Did you resolved your problem finally? I have a similar problem... – Felix Zeidler Nov 24 '15 at 15:10
1

Have you got this to work with the WcfTestClient utility? Always test and debug your services using that first, before trying to implement in managed code.

Once you've done testing in WcfTestClient, next try to call it from simply within a .NET console application. Isolate more bugs and then finally get it working within SharePoint code.

  • Thank you for your reply. One of my colleagues has already tested the procedure with WCFTestClient and console application. I worked with his procedure exactly, it works for him and not for me. – Sharadha Jayaraman Sep 3 '13 at 10:11
  • And yes, I did retest my service on a Console Application and it works as desired, just can't figure out what goes wrong in SharePoint :( – Sharadha Jayaraman Sep 3 '13 at 11:58
  • Im stuck exactly here... :( – Muhammedh Feb 9 '14 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.