WCF net.tcp 绑定(bind)、消息格式和安全问题

标签 wcf authentication authorization binding net.tcp

很抱歉这些愚蠢的问题,但是关于 WCF 的一些事情我无法理解。对于以下内容的一些建议将非常有用......

  • 在非常基本的层面上,WCF 使用二进制 (Net.Tcp)、HTTP 或 MSMQ 在线传输我的消息是否正确?
  • 但是,在所有情况下,无论数据如何传输,消息本身是否都以带有 header 和正文的 SOAP 格式传输?所以它是一种以 HTTP/S 或二进制格式传输的 XML 消息。
  • Net.Tcp 对我的客户端服务器应用程序来说是一个不错的选择吗?它类似于信使应用程序,因为客户端都是防火墙另一侧的远程用户到我的服务器。我正在阅读的大部分内容都在告诉使用 WS* 和 HTTP。
  • Net.Tcp 是否受标准保护且没有证书? - 也就是说 - 人们无法通过网络收听并解码传入和传出的数据。
  • 是否可以在没有安装证书的情况下使用 net.tcp 发送用户名和密码?
  • 如果是这样,我想我可以将它连接到我的成员(member)提供者并验证对我的服务契约(Contract)实现中每个方法的访问。
  • 我假设在用户名和密码安全的情况下,代理使用用户名和密码进行初始化,并且每个请求都会发送此信息。
  • 然后将为每个方法调用调用我的成员资格提供程序,并执行它需要做的任何事情来获得该方法的授权。

  • 很抱歉问题转储,但很高兴知道我是否以正确的方式思考 WCF 的工作方式。

    谢谢。

    最佳答案

    At a very basic level is it correct that WCF uses either Binary (Net.Tcp), HTTP or MSMQ to transfer my message on the wire?



    您将传输层与序列化机制混淆了。 WCF transports选项包括 TCP、命名管道、HTTP 和 MSMQ。 WCF serialisation选项是二进制、文本(包括 SOAP、POX 和 JSON)和 MTOM。

    However is it true that in all cases, regardless of how the data is transferred the message itself in in the SOAP format with headers and a body? So its a sort of XML message that is transmitted in either HTTP/S or in a binary format.



    否。WCF 使用 Message类作为通信的原子单元。它在结构上类似于 SOAP,但不是像 SOAP 那样的序列化格式。

    Is Net.Tcp a good choice for my client server app - its similar to a messenger app in that the clients are all remote users on the other side of the firewall to my server. Most things I am reading are telling to use WS* and HTTP.



    听起来 TCP 不是一个好的选择。除非您能够在端口 80 或 443 上操作服务器,否则防火墙可能会使 TCP 变得困难。根据我个人的经验,我还建议不要在 Internet 部署中使用带有 TCP 绑定(bind)的 WCF。当 TCP 连接丢失时,WCF 会让您跳过很多圈来捕获并重新建立它。 HTTP 绑定(bind)更容易管理。

    Is Net.Tcp secured by standard and without certificates? - that is - people cannot listen on the wire and decode the data thats going to and from.



    NetTCP binding is secured by default with TLS .

    Is it possible to send a username and password using net.tcp and without an installed certificate?



    您可以使用预安装的证书通过 TCP 绑定(bind)进行身份验证。您还可以在邮件标题中添加用户名和密码,但这是另一回事。

    If so I presume I can hook this up to my membership provider and authenticate access to each method on my service contract implementation.



    您可以使用 OperationContext 提取消息头。并提取您喜欢的任何信息并将其与您的身份验证提供程序一起使用。

    I presume that with username and password security, the proxy is initialised with the username and password and that this information is is sent with every request.





    Then my membership provider will be invoked for each method call and do whatever it needs to do to get the authorisation for the method.



    听起来你想看看How to: Use the ASP.NET Membership Provider .

    关于WCF net.tcp 绑定(bind)、消息格式和安全问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2441775/

    相关文章:

    azure - 如何从 Azure 应用程序注销?

    ios - 从登录 View Controller 过渡到主页

    security - 访问 token 和刷新 token 最佳实践?如何实现访问和刷新 token

    c# - 没有指定 authenticationScheme,也没有找到 DefaultChallengeScheme - ASP.NET core 2.1

    c# - 使用 NetTcpBinding WCF 服务获取 IEnumerable<T> 语义?

    javascript - 无法从 JavaScript 调用 Wcf 服务

    wcf - Web 服务和接口(interface)兼容性

    c# - WCF 托管在 WPF 中,我如何从 wcf 更改 MainWindow UI 中的控件?

    浏览器内客户端 API 的身份验证?

    rest - 使用 Powershell 和 REST API 添加 Azure 表实体