views:

86

answers:

1

I understand you can choose from a range of bindings, such as TCP, HTTP, HTTPS etc.

Am I correct in thinking it always uses SOAP to send data over this connection? I am watching a guide to WCF and it is talking about how exceptions are serialized into SOAP and sent to the client. I would have thought that not all bindings would use SOAP to send data, so I am a bit confused about how it works.

Although I understand the fundamentals of WCF, how to set up services and use a proxy on the client, it doesn't seem to have explained exactly how the data is packaged up to send.

Perhaps the answer is obvious, that it just uses XML / SOAP, but I would love to know for sure!

+6  A: 

No, not all. The WebHttpBinding is designed around REST protocols (HTTP GET, POX, JSON, etc.)

Technically, WCF is just a generic messaging protocol and can use any kind of encoding at all. The default and most common encodings are basicHttpBinding and wsHttpBinding, which are both based around SOAP/XML.

Then you have netTcpBinding, which uses a binary message encoding, netMsmqBinding, which uses the Microsoft Message Queue (MSMQ) protocol, and so on. There's really no hard-coded format for messages in WCF.

SOAP has its own specification for serializing exceptions (AKA faults), so the behaviour is always more or less the same when you use a SOAP-based binding; when you use other bindings, the faulting behaviour may be considerably different, in some cases actually swallowing exceptions unless you override the default behaviour (this is what happens in the webHttpBinding).

Aaronaught
Does this mean that exceptions are automatically serialized using the appropriate method?
SLC
@SLC: Well, no, it's up to the binding/behavior itself to decide what to do with faults. `WebHttpBinding`, for example, will actually swallow exceptions unless you set up custom behaviors.
Aaronaught
Thanks, your answer has been incredibly helpful!
SLC
+1 Good answer.
James Westgate