I am reading through the WCF 4.0 Cookbook, I am impressed by the unification protocol capability of WCF, and I just come up with this question:
Is a hosted service using 1 protocol like HTTP\named pipe? or a hosted service can be consumed by different protocol client like HTTP, named pipe at the same time?
If you setup the service with Multiple Bindings then yes it can listen and respond on different transport protocols.
Obviously if you initiate communication on http then you will get a response back over the same transport.
This msdn link provides details on when you would choose the different transports.
http://msdn.microsoft.com/en-us/library/ms733769.aspx
Related
WCF supports various protocols like TCP, HTTP, HTTPS, Named Pipes, MSMQ.
Please can you provide scenarios based on which the developer will choose an appropriate protocol when developing the WCF service project?
Also, can we have more than 1 protocol in the same web service project? Please can you give an example scenario.
you can have all protocols with little config in the web.config file. also you can have soap and restful interface both together. here you can find out more about the various protocols in wcf:
WCF - net.pipe vs. net.tcp vs. http Bindings
I am developing a WCF service (VS2010, .NET 4.0). If in the WCF service I utilise REST type functionality (i.e. decorate my methods with WebGet, etc), since REST heavily leverages the HTTP protocol, am I locked into hosting the WCF service as HTTP - i.e. do I have the option to host as net.tcp ?
Short answer - Yes, unless you want to write your own HTTP stack analog.
Is there any particular need in Tcp?
I am currently using wcf for one of my project and before to this I have also used web service but I have some doubts which I want to clarify.
1) In web service communication we use soap for cross platform communication, but I like to know why soap is needed, as XML itself is universally acceptable data exchange format than why there is need of soap which internally uses xml tags for data exchange
2) If I use gethttpenabled for data exchange instead of mex protocol in wcf it generates simple web service proxy for communication so like to know if my service is using nettcpbinding instead of basic or ws http banding so whether wcf and client can communicate or will create some issues.
3) As soap can be used with tcp protocol, whether tcp protocol can be used for communication between different platforms that is client in java and wcf in net
When I deploy the same service on different machines as they have different information that I need , how can I use my client gracely to consume these service .
You need to define the service endpoint you want to connect to in your client's config.
You cannot define a list of endpoints - if you need load-balancing features, you need to implement those on the server side and "hide" them behind a single service endpoint.
With .NET 4 and WCF 4, you have new capabilities you could check out:
WCF 4 has a new routing service which you can use to get called on a single URL, and you have control over how to "distribute" those calls to the actual back-end servers
WCF 4 also supports dynamic service discovery, so you could potentially just "yell out onto the network" and get back one service endpoint address that supports your contract you're interested in
Resources:
Developer's Introduction to WCF 4
10-4 Show on WCF 4 Routing Service
Content-based routing with WCF 4
WCF 4.0 Routing Service
WCF 4.0 Routing Service - Failover
Using WS-Discovery in WCF 4.0
Ad-hoc Discovery with Probing messages
It sounds like you want to connect to BOTH servers. you say they have different data that you need. Well, if you already know how to make a client to one of them, the easiest way is to define an entire other client to access the second one. You can define as many clients as you want in the config file. Then just call them both in code.
Could you please tell what is the difference between a WCF client and a non-WCF client?
When I generate proxy of a WCF service using svcutil and put that in client, what is created - wcf client or non-wcf client?
When should I use WCF client and non-WCF Client?
If you have a WCF service, its services are available to potentially several types of clients - both .NET applications using WCF themselves, or other apps.
Basically, any WCF binding that start with net.... is a .NET specific binding - only other .NET apps with WCF can connect to those services and call their methods.
The bindings with basic.... or ws...... typically are interoperable, e.g. using only industry standards like SOAP and WS-* standards - those can be called from Java, Ruby, PHP - you name it. Any language/system with a SOAP stack can call such a service (provided you get the configuration right on both ends)
The webHttpBinding is another special case - it's exposing it's services over REST - which means anything with a HTTP stack (pretty much every computer system and more and more phones and devices, too) can call its methods.
As long as you are programming your stuff in .NET, always use the WCF client - it's the easiest and the best if it's available. If you need to call your WCF service from a PHP client, of course, then you have to use PHP technology and something that's compatible between the two worlds....