Question

I want to expose my Service Layer (which is currently written as standard class library with POCOs) for external as well as internal consumption. External clients will use it over REST style APIs while internally my MVC app will use it over net.tcp binding for better performance.

How do I do this elegantly? I can write 2 wrappers one for REST using VS2010 Beta 2 REST features and other using standard WCF bindings.

Can I do this in one wrapper? or better just refactoring my existing services as WCF and expose on various endpoints using different bindings like WebHTTPBinding, WsHttpBinding, etc.

Regards,

Ajay

Was it helpful?

Solution

Your service library will only contain the implementation of the service - your service (and data) contracts should be in their own separate "Contracts" assembly.

The question of hosting and what protocol to use is handled by your service host - this can be IIS or a separate NT Service or a console app or something. That is totally independant of your service class and your service library.

So yes - you can easily create a service library and then expose that service over a multitude of endpoints in your service host - those two things should be kept totally separate from one another.

OTHER TIPS

Sure you can just add more of them to the configuration file or using the code.

VS 2010 Beta 2's REST features are themselves built on top of WCF, so if you want to use them you'll have to refactor your service into a WCF service anyway. At that point, as Dani and marc_s say, you can very easily add additional endpoints to the service through the configuration file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top