0
votes

I have a Sharepoint 2010 webpart that calls a WCF service.

I've created a service proxy and manually coded the endpoint, see below.

In a conventional WCF client I'd use the config files for the configuration and use transforms when I was buiding for deployment to different environments.

How would I achieve the same through a Sharepoint webpart? I want to put the configuration somewhere that it can be changed for different build configurations.

ie. For a local deployment during testing, then a test server, production. We're trying to automate this as much as possible.

Thanks, Tim

UPDATE: I'm aware that you need to put config data in the web.config file in sharepoint. I'm looking for a way to put these config settings into source control and have them automatically populate / deploy for different builds and environments.

namespace CombinedPortal.WcfClient { public class FrameworkServiceProxy : IFrameworkService { private IFrameworkService _proxy;

    public FrameworkServiceProxy()
    {
        var endpoint = new EndpointAddress("http://server:1234/FrameworkService.svc");
        var binding = new WSHttpBinding(SecurityMode.None);

        _proxy = new ChannelFactory<IFrameworkService>(binding, endpoint).CreateChannel();
    }

    public Framework GetCurrentFramework(double uniqueLearnerNumber)
    {
        var fw = _proxy.GetCurrentFramework(uniqueLearnerNumber);
        return fw;
    }
} }
1
You could access your SharePoint's web.config to get the keys you need, and set those up in the all the environments you will deploy it. Is this automated enough?Alexandre Machado

1 Answers

0
votes

Your code is C# code which executes on the server.

When then user presses a button on a web part there is a POST back to the Sharepoint web server, where the C# code executes.

It is therefore the web.config of your SharePoint site which is used.