Common methods/implementation across multiple WCF Services
Posted
by Rob
on Stack Overflow
See other posts from Stack Overflow
or by Rob
Published on 2010-03-19T18:00:10Z
Indexed on
2010/03/19
18:01 UTC
Read the original article
Hit count: 190
wcf
|asp.net-3.5
I'm looking at implementing some WCF Services as part of an API for 3rd parties to access data within a product I work on. There are currently a set of services exposed as "classic" .net Web Services and I need to emulate the behaviour of these, at least in part.
The existing services all have an AcquireAuthenticationToken method that takes a set of parameters (username, password, etc) and return a session token (represented as a GUID), which is then passed in on calls to any other method (There's also a ReleaseAuthenticationToken method, no guesses needed as to what that does!).
What I want to do is implement multiple WCF services, such as:
- ProductData
- UserData
and have both of these services share a common implementation of Acquire/Release. From the base project that is created by VS2k8, it would appear I will start with, per service:
public class ServiceName : IServiceName
{
}
public interface IServiceName
{
}
Therefore my questions would be:
- Will WCF tolerate me adding a base
class to this,
public class ServiceName : ServiceBase, IServiceName
, or does the fact that there's an interface involved mean that won't work? - If "No it won't work" to Question 1, could I change IServiceName so it extends another interface, IServiceBase, thus forcing the presence of Acquire/Release methods, but then having to supply the implementation in each service.
- Are 1 and 2 both really bad ideas and there's actually a much better solution that, knowing next to nothing about WCF, I just haven't thought of?
© Stack Overflow or respective owner