Is it possible to define multiple bindings in the same service - wcf

I have a WCF Service.
Is it possible to define a WCF service to have mulitple bindings
like
Method1 - WSHttpbinding
Method2 - BasicHttpbinding
Method3 - NETTcpBinding
Thanks.

No, you can't set a binding on method level.
What you can do: expose the entire service on multiple endpoints, where each endpoint is configured with a different binding (WsHttp, BasicHttp, Tcp, etc).

Related

what is the use of multiple endpoints in WCF service?

i have seen people decorate their config file with multiple endpoints in WCF service. is there any reason. when one endpoint is ok then why two or more endpoints are require?
tell me small situation when multiple endpoints is required.
Scenario for multiple endpoints:
Service wants to expose more than one type of binding.
Service wants to expose more than one contract on the same binding.
Service wants to expose same binding and contract on different addresses.
http://debugmode.net/2010/05/25/multipleendpoint/

What is the underlying type of Binding used by WCF Data Services

While creating a WCF data service, we do not have to define Endpoints in the config. What is the type of Binding that it uses, by default? Is there a way we can change the type of Binding being used?
WCF Data Services is an extension of the WCF REST services, and thus uses the webHttpBinding.
This binding cannot be changed for WCF Data Services - the whole architecture is so intimately tied to the HTTP and REST paradigm, it won't work over SOAP:
From what I remember, those created with ServiceHostFactory use basicHttp.
From playing with WebServiceHostFactory I could only seem to connect to it with WebHttpBinding leading me to believe that is the binding it uses underneath.
It states on: http://msdn.microsoft.com/en-us/library/system.servicemodel.activation.webscriptservicehostfactory.aspx that WebScriptServiceHostFactory uses the WebHttpBinding
Hope that helped,
Anthony
EDIT: This page: http://msdn.microsoft.com/en-us/library/bb412204.aspx makes me believe that WCF Web Services default to using WebHttpBinding

WCF Callback Service hosted over basicHttpBinding and wsDualHttpBinding

I have a callback service that is hosted over wsDualHttpBinding. I'm looking to add a client that will poll for the data rather than receive the callback (will be a mobile device using wince for demo purposes). I was curious what the best way to do this is? You cannot create a client proxy using NetCFSvcUtil with a service hosted with wsDualHttpBinding (I understand that), but you cannot host a callback service over basicHttpBinding. I really need the same service hosted over both basicaHttpBinding (clients will poll for data) and wsDualHttpBinding (callback will notify clients of data). Any ideas on the best way to handle this without creating two separate services to host the same data?
What do you mean by two separate services hosting the same data? Do you expect to share same service instance to handle both wsDualHttpBinding and basicHttpBinding requests?
Your current problem is that service interface for duplex communication cannot be used for basicHttpBinding. You have to create second service contract and implement it in the same service. In that case you can expose two endpoints for the service: one duplex with WSDualHttpBinding and one with BasicHttpBinding. Endpoints must have different relative addresses. From the perspective of the client those endpoints are separate services - each of them requires separate client proxy. So unless your service is singleton you will have new service instance for each client proxy. New service instance means no data sharing.
Thera are some possibilities to modify this behavior but it means replacing Instance provider.

Can you only use webHttpBinding with REST?

I know you can use multiple bindings, but if you implement a REST Service, must you use the webHttpBinding?
The webHttpBinding is what tells the WCF framework to communicate in a RESTful fashion - any other binding would define a different protocol. In your comment, you ask about wsHttpBinding - If you used that binding, you would not have a REST service, you'd have a SOAP web service.
You don't need to use directly WebHttpBinding. You can also use custom binding or your own binding but these bindings have to use HttpTransportBindingElement and WebMessageEncodingBindingElement. Both these binding elements are used by WebHttpBinding.

WCF using REST, having some binding questions

I am really confused right now and I can't get any right answers anywhere.
My confusions are:
1) Isn't wsHttpBinging (which is beefed up basicHttpBinding) used in SOAP instead of REST and REST only uses webHttpBinding?
2) Also, DOES silverlight 4 with WCF (REST) support wsHttpBinding (VS2010)? I read that it does not everywhere on the net but I some how got silverlight 4 working with REST using wsHttpBinding.
NOTE: I am using Factory="System.ServiceModel.Activation.WebServiceHostFactory". Is this factory setting somehow bypassing my web.config setting for wsHttpBinding to make it work with webHttpBinding and i am thinking by my wsHttpBinding is working?
Thank you.
WCF uses SOAP by default - all binding except the webHttpBinding use SOAP.
If you want to do REST, you need to use the webHttpBinding.
1) Isn't wsHttpBinging (which is
beefed up basicHttpBinding) used in
SOAP instead of REST and REST only
uses webHttpBinding?
Yes - wsHttpBinding is a SOAP-based protocol - webHttpBinding is REST
2) Also, DOES silverlight 4 with WCF
(REST) support wsHttpBinding (VS2010)?
Silverlight 4 supports basicHttpBinding (SOAP), netTcpBinding (new in SL4 - SOAP) and webHttpBinding (REST).
NOTE: I am using
Factory="System.ServiceModel.Activation.WebServiceHostFactory".
Is this factory setting somehow
bypassing my web.config setting for
wsHttpBinding to make it work with
webHttpBinding and i am thinking by my
wsHttpBinding is working?
Yes, if you use the WebServiceHostFactory in your SVC file, then you're really getting the webHttpBinding (REST) implicitly. The WCF runtime will not look at your web.config for infos - it has all the information and settings it needs when you use WebServiceHostFactory - and you get webHttpBinding.