通过 NetTcpBinding 连接到 php 中的 WCF 服务
我找不到这个问题的重复项,但老实说我希望我不是第一个问这个问题的人。
我的 LAN 内有一个 WCF 服务。对于我的局域网上的 .NET 客户端,NetTcpBinding 是合适的绑定。然而,我的客户之一是 PHP Web 应用程序。有什么办法可以做到这一点吗?
更新:我很清楚我可以有多个端点。我想知道与 php 应用程序中的 wshttp 相比,我是否可以享受 nettcp 的速度、减少的网络流量和无延迟。
它恰好是一个在 Windows 上运行的 PHP 应用程序,因此 COM interop 或 .NET Interop 可以工作。我想知道是否有一个“本机”解决方案,例如 pecl 模块或 pear 库。
I can't find a duplicate for this question, but I honestly hope I'm not the first to ask.
I have a WCF service that is sitting inside my LAN. For .NET clients on my lan, NetTcpBinding is the appropriate binding. However, one of my clients is a PHP web application. Is there any way to do this?
Update: I am well aware I can have multiple endpoints. I want to know if I can enjoy the speed, reduced network traffic and lack of latency of nettcp compared to wshttp from a php app.
It happens to be a PHP app running on windows so COM interop or .NET Interop would work. I'm wondering if there is a "native" solution, such a a pecl module or pear library.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
NetTcpBinding 仅用于“WCF 到 WCF 通信”。 (MSDN)
此绑定使用专有协议来通信,并且它并不意味着可互操作,因为它针对 WCF 到 WCF 进行了优化。
您的 WCF 服务可以有不同的端点。为什么不公开另一个具有可以从 php 应用程序轻松使用的绑定的端点? (如 BasicHttpBinding 或 WebHttpBinding)
NetTcpBinding is intended "for WCF-to-WCF communication" only. (MSDN)
This binding uses a proprietary protocol to communicate, and it is not meant to be interoperable since it is optimized for WCF-to-WCF.
You could have different endpoints for your WCF service. Why don't you expose another endpoint with a binding that could be consumed easily from your php application? (like BasicHttpBinding or WebHttpBinding)
您可以向现有服务端点添加另一个绑定。那么,除了 nettcp 绑定之外,为什么不添加 basichttp 或 wshttp 绑定呢?它只是配置文件中的几行,不需要更改任何代码。
You can add another binding to an existing service endpoint. So why don't you just add a basichttp or wshttp binding in addition to the nettcpbinding. It is just a few lines in your config file and doesn't require any code change.
以下选项是可能的黑客攻击。我将它们放在那里供其他发现这个问题的人使用。
此允许您使用非托管导出创建 .NET 程序集,您可以从自定义 PHP 模块,
Phalanger 将 PHP 解释为 .NET 运行时。它还使您能够完全访问 .NET API。我只是玩了一下这个。但是,它肯定会读取您的 web.config 文件。如果它不尊重 web.config 的 WCF 服务方面,我会使用 此 PowerShell 脚本,最初由 Christian Glessner 开发,作为完全在代码中配置 WCF 服务客户端存根的参考。
The following options are possible hacks. I include them there for others that find this question.
This allows you to make a .NET assembly with unmanaged exports you could call from a custom PHP module,
Phalanger interprets PHP into the .NET runtime. It also gives you full access to the .NET API. I've only toyed a little with this. However, it definitely reads you web.config file. If it does not respect the WCF services aspect of the web.config, I would use this PowerShell script, originally developed by Christian Glessner, as a reference for configuring a WCF service client stub completely in code.