WCF using REST, having some binding questions - wcf

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.

Related

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

wsHttpBinding on the wcf service and web reference on the client don't work

I am using wsHttpBinding with a WCF service.
I've added a web reference and I've got the web proxy (it is based on SoapHttpClientProtocol).
Also I've tried to build a proxy using wsdl.exe and the actual wsdl generated by the wcf service (http://zzzz/zz.svc?wsdl).
When the client calls the service, I get the following error:
The SOAP action specified on the message, '', does not match the HTTP SOAP Action, 'http://tempuri.org/Service1/Operation1'.
Why doesn't the client (the web proxy) work with my WCF service?
What steps should I take to make them work?
I am running .NET FW 3.5 and ASP.NET 2.0.
You cannot consume service exposed on wsHttpBinding with default configuration by old ASMX proxy. You must either use add service reference / svcutil or change your binding to basicHttpBinding. Default configuration of wsHttpBinding uses advanced security and ASMX doesn't support it.

WCF interacting (callback) with .Net 2.0 app

At first I had to make 2.0 work with WCF service. I accomplished that using BasicHttpBinding . Since BasicHttpBinding doesn't support Duplex callback, I can't make the server ping the client. Any ideas????
Thanks
If you want WCF to do this, it's not possible over the BasicHttpBinding. You need wsDualHttpBinding or NetTcpBinding if you wish to establish a callback channel out-of-the-box with WCF. You can also try to write a CustomBinding, but utilizing .NET 2.0 for the client is going to limit what you can do.

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.

Silverlight + smart client operations in one service?

For my project's web services I want to support desktop clients and silverlight clients. Should I write a separate web service for each or put all the operations in one service? If I put them all in one, I have to go with basicHttpBinding. The winforms app uses wsHttpBinding now, what do I lose going with basicHttpBinding?
I very strongly recommend you read this thoroughly:
"Silverlight and WCF Feature Comparison"
http://msdn.microsoft.com/en-us/library/cc896571(VS.95).aspx
There are quite a few gotchas when developing a web service for silverlight usage, especially if you already have a wsHttpBinding solution. Good luck!
EDIT: also I found this article useful:
WCF : BasicHttpBinding compared to WSHttpBinding at SOAP packet level
http://geekswithblogs.net/claeyskurt/archive/2008/04/22/121508.aspx
Use one web service with two endpoints, that would allow you to support basicHttpBinding as well as wsHttpBinding.
The difference between the two bindings is that basic is Soap 1.1 whereas ws is Soap 1.2 and WS-Addressing Specifications, in addition wsHttpBinding offers more security options