WCF 是否总是使用 SOAP 通过您的绑定发送信息? [英] Does WCF always use SOAP to send information over your binding?

查看:29
本文介绍了WCF 是否总是使用 SOAP 通过您的绑定发送信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道您可以从一系列绑定中进行选择,例如 TCP、HTTP、HTTPS 等.

我认为它总是使用 SOAP 通过此连接发送数据是否正确?我正在观看 WCF 指南,它正在讨论如何将异常序列化为 SOAP 并发送到客户端.我原以为并不是所有的绑定都会使用 SOAP 来发送数据,所以我对它的工作原理有点困惑.

虽然了解了WCF的基本原理,如何在客户端设置服务和使用代理,但似乎并没有具体说明数据是如何打包发送的.

也许答案很明显,它只使用 XML/SOAP,但我很想知道!

解决方案

不,不是全部.WebHttpBinding 是围绕 REST 协议(HTTP GET、POX、JSON 等)

从技术上讲,WCF 只是一个通用的消息传递协议,可以使用任何类型的编码.默认最常见的编码是basicHttpBindingwsHttpBinding,它们都基于SOAP/XML.>

然后是 netTcpBinding,它使用二进制消息编码,netMsmqBinding,它使用 Microsoft 消息队列 (MSMQ) 协议,等等.WCF 中的消息确实没有硬编码格式.

SOAP 有自己的序列化异常(AKA 错误)规范,所以当您使用基于 SOAP 的绑定时,行为总是或多或少相同;当您使用其他绑定时,错误行为可能会大不相同,在某些情况下实际上会吞下异常,除非您覆盖默认行为(这就是 webHttpBinding 中发生的情况).

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!

解决方案

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

这篇关于WCF 是否总是使用 SOAP 通过您的绑定发送信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆