pramod choudhari
pramod choudhari

Reputation: 313

Splitting WCF service with common configuration files

I have a WCF service.

Which has 3 service contract.

    [ServiceContract(Name = "Utility"]

public interface IService { //method defination }

[ServiceContract(Name="Documents"]

public interface IDocumentService { //method defination }

[ServiceContract(Name = "Lists"]

public interface IListService  { //method defination }

And it is implemented by the a partial class.

Service.cs:

[ServiceBehavior(Name="SharePoint")]
public partial class Service : IService
{

*Implementation of IService Methods*

}

DocumentService.cs:

public partial class Service : IDocumentService
{

*Implementation of IDocumentService Methods*

}

ListService.cs:

public partial class Service : IListService
{

*Implementation of IListService Methods*

}

Now inside this project I have Configuration files.

Which contains Database Connection String and other Application Settings

I have created Solution and Added 3 WCF service application.

Now I split the service in to 3 different service application with in solution. Like

  [ServiceBehavior(Name="SharePoint")]
public class Service : IService
{

*Implementation of IService Methods*

}

DocumentService.cs:

public class DocumentService: IDocumentService
{

*Implementation of IDocumentService Methods*

}

ListService.cs:

public class ListService: IListService
{

*Implementation of IListService Methods*

}

All 3 Service Application contains it own Configuration files.

I want to make common configuration files among all thease Service Application. how do Share them??

Upvotes: 2

Views: 338

Answers (3)

Daniel Dyson
Daniel Dyson

Reputation: 13230

You could use ConfigGen to do this. If you configure your templates and settings files to point to a network share, then all of your configs will be generated at build time (or from the command line at packaging time) from the same source.

The added advantage is that you can use this to generate configs for all of your environments at the same time, from the same place.

Upvotes: 2

kroonwijk
kroonwijk

Reputation: 8400

Make a shared application configuration file in one of the service application projects, or (even better) create a "common" project that contains the application configuration file. Now look at the Adding an Existing Item as a Link section, to add that file in the different projects as a Link. It will refer to the same physical file that is shared.

Upvotes: 0

SliverNinja - MSFT
SliverNinja - MSFT

Reputation: 31641

You just need to use external configuration files. Add a solution folder to your project and create the shared configuration files you want (connection strings, app settings, etc.). You can see this post (or MSDN) for managing external app settings (file attribute), and this post for managing external connection strings (configSource attribute).

Upvotes: 0

Related Questions