ASP.NET MVC using Loosely-Coupled WCF Web Service

The reason I need a loosely coupled WCF is because the Entity Framework is tightly coupled. When I say “loosely coupled”, there is no need to instantiate the database context or add a link to the WCF service. It simply relies on a web configuration or some kind of .ini file that does not require compilation when developers need to change servers, the IP address or the service URL.

Instead, the MVC (say, the controller) will simply send a request message and then receive the response data from the WCF service. But still we cannot afford, without having database-based models (since we need it in intellisense for marking up views), where the WCF will receive the data. Say we already have a class of database objects, create some repository that links WCF data to MVC models.

What I mean for the WCF web service is that it ONLY contains messages, no more passing an object reference, because this is a new SOA definition. It makes sense to pass messages instead of objects.

Is this a better approach? As for scalability and performance, I don't want to offend Entity Framework fans.

+4
source share
1 answer

This is a fully justified approach for defining a WCF web service in terms of message schemes that simply use basic types, so clients do not need to know anything about WCF in order to use this service. WCF would be useless to interact with other platforms (e.g. Java) otherwise.

Understand that WCF is a common and powerful environment for implementing communications over various transport protocols. It can be equally effectively used for raw XML messaging, as well as for programming in terms of objects. Serialization of objects and deserialization is an optional additional structure, not a requirement. (Actually, there’s no such thing as “passing a reference to an object” - in the end, this is XML information material that moves through the communication channel. In addition, the Entity Framework is not part of WCF — it is a separate ORM structure that you can use with WCF if you want, but it's your choice.)

Scalability and performance are completely orthogonal to the design of the service in terms of its data and operating contracts. You must be sure that any approach to defining your services is best for your application. If these are XML messages, this is normal - do not let anyone else talk about it otherwise.

+1
source

Source: https://habr.com/ru/post/1397993/


All Articles