views:

11

answers:

1

We have a WCF service which will be accessed from outside systems. Under certain conditions, we want our responses to include some descriptive text. Because the calling system isn't under our control, we need to return the text itself, not an error_code or similar abstraction. The text we return needs to be human-readable, and it must be configurable post-deployment, in case certain customers want to change the phrasing.

In ASPX or ASMX, this would be easy: I'd put the human-readable text into a localResource or globalResource, and be done with it. Clients could use satellite assemblies or other resource-editing tools to modify the text post-deployment. However, I can't seem to find a similar construct within WCF.

What is the preferred way to externalize user-readable strings in WCF?

A: 

Well, WCF is not ASP.NET, so you cannot use the ASP.NET local resources / global resources.

But WCF code is still .NET code, and .NET itself has a strong resource model (the System.Resources namespace - see the MSDN docs on the ResourceManager class as a starting point).

You can still use resource files, even for non-ASP.NET applications - and that's exactly what I'd do here.

Package up your text strings, icons, what have you, into resources. You can define locale-specific versions of those resources, and depending on e.g. some WCF header value, pick the right locale for that particular call, and return any textual information from the appropriate resource file.

marc_s
Wow, WCF has no built-in helper framework (akin to LocalResources) like ASPX/ASMX does? That's kinda surprising/disappointing. But you're right - the "raw" ResourceManager framework is solid and pretty easy to use - I'm going to roll with it. Thanks for your help!
mikemanne