Click here to Skip to main content
14,843,635 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I created a windows application. When I run it, it saves the details to the database.

I saw some posts that they are using WCF Service to do this...

Can anyone tell me what is the reason for using WCF Services in this scenario..

What I have tried:

I created a windows application, and when i hit submit button, it saves data into database.
Posted
Updated 27-Apr-16 8:24am
Comments
Afzaal Ahmad Zeeshan 27-Apr-16 14:39pm
   
Besides, if you want to create a client-server application, my recommendation would be to use ASP.NET Web API instead of WCF; it works on native HTTP protocl.
Sergey Alexandrovich Kryukov 27-Apr-16 15:09pm
   
I would say, not quite. You cannot assume anything about the possible application, and I would guess this is pure study. Client-server can be considered in the widest sense of this term. And then WCF has apparent benefits. It still can use HTTP, but the channels can be easily replaced with the channels using other protocols, without any change in application code. Besides, WCF solution can be much, much lighter; for example, it can be self-hosted. Using ASP.NET can only be justified if the HTTP server is used for something else, say, serving up ASP.NET with IIS. In general case, this is not so. Aren't you biased to ASP.NET because you do Web development? But out inquirer started with Windows application. So why?

So, in general case, I would strongly recommend WCF.

—SA
Afzaal Ahmad Zeeshan 28-Apr-16 14:36pm
   
Not really, I left ASP.NET when 2 years ago I heard you say, "I don't do web." I don't build web applications at all, and personally I was also trying to communicate from a desktop approach.

The major benefit of ASP.NET Web API over WCF is that you can use it in any framework at all, no need for ClientBase stuff. Besides, who wants to use SOAP, when you can do things in JSON, with smaller size over network.

I have also made applications where data is backed up on a network hosted database, somewhere on external network. WCF doesn't play fair, when you want to support devices that cannot run .NET framework. Linux environment for example, much more... JSON-formatted content from Web API would be much better than using SOAP or other ones that WCF supports.

Now, I am willing to give WCF another try to see if it can beat ASP.NET Web API. :-)
Sergey Alexandrovich Kryukov 28-Apr-16 15:10pm
   
All right. "Who wants to use SOAP" can be replied: Who wants to use SOAP? It's one of the worst XML formatters from the set of all widely used ones. But WCF can use any... and so on...
—SA

1 solution

Several reasons. This approach hides the potentially unsafe SQL interface, hides direct access, authentication, and so on… More importantly, if hides the access to unwanted functionality, and more generally creates a façade abstracting out database functionality. This façade can be very different from the usual SQL interface (or other database models), both general and specific to a particular database project. First of all, it can be totally semantic, or domain-oriented (meaning: application-field domain). During the evolution of the product/service, the database can be completely replaced which still will be completely not noticeable for the WCF interface users. Please see: Facade pattern — Wikipedia, the free encyclopedia[^].

Database layer and WCF layer become different tiers. In other words, the benefits of this solution comes as the general benefits of multitier architecture. Please see: Multitier architecture — Wikipedia, the free encyclopedia[^].

—SA
   
Comments
Member 12478311 27-Apr-16 14:32pm
   
Thanks
Sergey Alexandrovich Kryukov 27-Apr-16 15:02pm
   
You are very welcome.
Good luck, call again.
—SA
Sascha Lefèvre 27-Apr-16 15:28pm
   
5ed
Sergey Alexandrovich Kryukov 27-Apr-16 15:47pm
   
Thank you, Sascha.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900