Abhi
Abhi

Reputation: 5561

WCF service TCP/Ip vs Http protocol for Internet vs Intranet service consumption

I have a WCF service, which can be consumed through jQuery based web app in internet and also through WPF app in local intranet.

Should I choose http or TCP protocol OR should i make two similar services with http protocol for internet and TCP protocol for Intranet.

Upvotes: 2

Views: 2674

Answers (3)

atconway
atconway

Reputation: 21314

Honestly I recommend to do both, and that is what I've done as well. I think it's nice to expose service 'x' and be able to connect either via 'y' or 'z' depending on the consuming parties needs.

When I 1st decided to do this, I figured exposing multiple binding types for the same service would be trivial. After all WCF is all about options, so why not expose a couple of options like you want, right? The tricky part is you can not have (2) different services with different bindings (say HTTP and netTCP) both consuming the same Service Contract. You will get an error trying to host a service like this.

I came up with a simple abstraction using an additional Interface to allow this very thing. Now you will have (2) separate contracts to implement, 1 for each binding type, but still only have a single implmeneted code base underneath. Have a look at a post I wrote that explains this futher with a code example:

Exposing Multiple Binding Types For The Same Service Class In WCF

Upvotes: 2

Davide Piras
Davide Piras

Reputation: 44605

I am not an expert of WCF but here my two cents:

in WCF bindings are only a matter of configuration, meaning the web.config for the WCF end point and the app.config for your WPF client.

You need only one service and eventually multiple bindings/endpoints in the server web.config

client applications will connect using one of the two end points and a client binding/protocol as needed without any need for you to have two services or to make any specific change.

in an intranet netTCPbinding is probably the fastest option as it transfer binary data, in Internet httpBinding should work well; Notice that you could use httpBinding also in the intranet with no issues and if it will be much slower or fully equivalent to the netTcp binding has all to be proven depending also on your usage transer type/content.

Upvotes: 1

Ankur
Ankur

Reputation: 33657

I would suggest to use HTTP, it will work for internet as well as intranet. Also for exposing the service on both you don't need to create 2 services, just create proper bindings in the config and then same service will get exposed on both protocols.

Upvotes: 1

Related Questions