Yeldar Kurmangaliyev
Yeldar Kurmangaliyev

Reputation: 34189

What are advantages of local WCF services?

I have several WCF services which contain business logics code, hosted on IIS.
Due to security issues it is only called locally, and it will always be.
I was thinking about using self-hosted applications with NetPipe binding and came to a question: is there any advantage in using WCF at all, in my case? I could simply use these libraries directly.

So, instead of having

// Server
ServiceHost sh = new ServiceHost(typeof(MyService), 
                                 new Uri("http://localhost:3000/myservice"));
sh.Open();

// Client
var ch = ChannelFactory<IMyService>.CreateChannel(new BasicHttpBinding(), 
             new EndpointAddress("http://localhost:3000/myservice"));
var result = ch.MyMethod();

I could simply do

var result = new MyService().MyMethod();

It would improve performance because it won't instantiate services, serialize \ deserialize data etc.

What advantages does WCF give in my case, except for scalability and elasticity? Is there any sense in not abandoning WCF usage?

P.S. If you are interested in "why you used WCF at all", then it was planned that they are scalable WsHttpBinding-services, called remotely. However, this arhitecture was declined by informational security specialists of our company. Now, I can't choose between continue to use WCF or not.

Upvotes: 2

Views: 90

Answers (2)

tom redfern
tom redfern

Reputation: 31750

Due to security issues it is only called locally, and it will always be

If this is an iron clad 100% gurantee then yes as jgaufin says you'd definately be better off consuming the service in-process rather than out of process.

However, presumably the service was originally hosted out of process for a reason. It would be good to know what this reason was before making such a change.

If it already uses netpipe, the performance gain will be small, so unless you're up against it performance wise, this may not justify the cost of changing it.

Upvotes: 0

jgauffin
jgauffin

Reputation: 101130

There is no advantage.

WCF would be motivated if you had one or more of the following:

  • Multiple applications need to invoke the services
  • Caching
  • Part of different business domains
  • Separate transaction handling
  • All consumers are clients (DB calls should typically be at server side)

Doesn't matter if those things are for local or remote apps.

Upvotes: 2

Related Questions