连接到 PHP 中具有 NetTCP 绑定和 BasicHttpBinding 的 WCF 服务

发布于 2024-08-15 08:35:52 字数 695 浏览 10 评论 0原文

我有 WCF 服务。它有多个客户端和三个端点。端点绑定是 nettcp、wsHttp 和 basicHttp。如果我尝试通过 php 内置的 SoapClient 类连接到它,如下所示:

$service = new SoapClient
("http://service.companyname.local:6666/Service/?wsdl",
 array(
         "location" => "http://service.companyname.local:6666/Service/Basic",

    "trace" => true,
    'soap_version' => SOAP_1_1
     )
);

我得到以下信息:

PHP Fatal error:  SOAP-ERROR: Parsing WSDL: PHP-SOAP doesn't support transport 'http://schemas.microsoft.com/soap/tcp' in c:\www\client.php on line 666

现在我的解决方法是手动保存 wsdl 并删除 nettcp 绑定。有没有一种解决方法可以让我使用自动生成的 wsdl?我可以在 web.config 中隐藏 wsdl 的绑定吗?我可以在不同的绑定上生成不同的 wsdls 吗?我不想部署两个服务主机。

I have a WCF service. It has multiple clients and three endpoints. The endpoint bindings are nettcp, wsHttp and basicHttp. If I attempt to connect to it via php'd builtin SoapClient class like so:

$service = new SoapClient
("http://service.companyname.local:6666/Service/?wsdl",
 array(
         "location" => "http://service.companyname.local:6666/Service/Basic",

    "trace" => true,
    'soap_version' => SOAP_1_1
     )
);

I get the following:

PHP Fatal error:  SOAP-ERROR: Parsing WSDL: PHP-SOAP doesn't support transport 'http://schemas.microsoft.com/soap/tcp' in c:\www\client.php on line 666

Right now my workaround is to save the wsdl manually and remove the nettcp binding. Is there a workaround that will allow me to use the automatically generated wsdl? Can I hide a binding from the wsdl in web.config? Can I generate different wsdls on different bindings. I don't want to deploy two service hosts.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

旧时光的容颜 2024-08-22 08:35:52

当您说不想部署两个服务主机时,我假设您在 Windows 服务中自托管单个 ServiceHost。我通过构建一个通用服务主机解决了这个问题,该主机可以在内部托管尽可能多的服务实现(例如,它是配置中每个服务条目的新 ServiceHost)。这样,我就可以根据需要在单个 Windows 服务中灵活托管任意数量的服务实现。这将通过允许您将 basicHttp 绑定服务与其他服务分开来解决您的问题,以保持 WSDL 干净。有一些开源示例(这是一个)。

我能想到的唯一其他方法是公开从 WsdlExporter 构建的您自己的自定义元数据端点(请参阅 这里

祝你好运!

When you say you don't want to deploy two service hosts, I assume you're self-hosting a single ServiceHost in a Windows Service. I solved this problem by building a generic service host that can host as many service impls internally as I want (eg, it new's a ServiceHost for each service entry in the config). That way, I can flexibly host as many service impls in a single Windows Service as I need. This would solve your problem by allowing you to separate the basicHttp bound service from the others to keep the WSDL clean. There are some open-source examples of this floating around (here's one).

The only other way I could think of to do it would be to expose your own custom metadata endpoint built from WsdlExporter (see here)

Good luck!

⒈起吃苦の倖褔 2024-08-22 08:35:52

我目前正在研究的另一个选择是 PHP 的第三方 SOAP 客户端,名为 WSF-PHP

Another option I am currently researching is a third party soap client for PHP called WSF-PHP.

野味少女 2024-08-22 08:35:52

我提交了 PHP 功能请求。如果他们实现了这一点,我会将其标记为正确答案。不过,我仍然愿意接受更好的解决方法。

更新:我提交了一个补丁来实现这一点。我正在等待其批准。
更新:补丁已提交至 svn。等待 PHP 的下一个版本。
更新:补丁现已成为 PHP 5.3.3 和 5.2.14 的一部分。

I filed a feature request with PHP. If they implement this I'll mark this as the correct answer. I'm still open to better workarounds though.

UPDATE: I submitted a patch to implement this. I am awaiting its approval.
UPDATE: Patch committed to svn. Awaiting the next release of PHP.
UPDATE: Patch is now part of PHP 5.3.3 and 5.2.14.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文