Does WCF always use SOAP to send information over your binding?

不问归期 提交于 2019-12-18 11:33:28

问题


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!


回答1:


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).



来源:https://stackoverflow.com/questions/2760839/does-wcf-always-use-soap-to-send-information-over-your-binding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!