在 PHP5 中禁用本机 Soap 类并使用 nuSoap?
上周我一直在开发代码以使用 nuSoap 库连接到 Web 服务。我刚刚将代码部署到生产中,但立即开始出现我以前从未见过的错误。我将问题追溯到试图实例化新的soapclient 对象的一行代码。事实证明,这两个库都有一个名为“soapclient”的类,并且在生产中创建的类来自本机 Soap 库,而不是我包含的 nuSoap 库。如何禁用本机 Soap 功能并严格遵守 nuSoap?
I've spent the last week developing code to connect to a Web Service using the nuSoap library. I just deployed the code to production, but immediately started getting error's that I hadn't seen before. I traced the problem back to a line of code that is trying to instantiate a new soapclient object. It turns out that both libraries have a class named 'soapclient' and the one that's being created in production is from the native Soap library, not the nuSoap library that I'm including. How can I disable the native Soap functionality and stick strictly to nuSoap?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
随着 PHP5 的发布,php_soap 扩展中包含了一个
soapclient
类。 NuSOAP 已将其类重命名为nusoap_client
。如果您的 NuSOAP 副本是最新的,您应该能够使用它。这不会禁用 php_soap 扩展,但应该允许您使用 NuSOAP 类而不会进一步发生冲突。With the release of PHP5 there is a
soapclient
class included in the php_soap extension. NuSOAP has renamed its class tonusoap_client
. If your copy of NuSOAP is current you should be able to use that. This doesn't disable the php_soap extension, but should allow you to use the NuSOAP class without further conflict.啊,没关系。 NuSoap 0.7.3(我正在使用)将类名更改为“nusoap_client”,专门为了避免这种冲突。它们还包括向后兼容性检查,如果未加载本机 Soap 扩展,则使用“soapclient”为该类别名,这就是为什么我没有在我的开发计算机上捕获它。
参考:http://code.google.com/ p/nusoap-for-php5/issues/detail?id=2
Ah, nevermind. NuSoap 0.7.3 (which I was using) changed the class name to 'nusoap_client' specifically to avoid this conflict. They also included a backward compatibility check that aliased that class with 'soapclient' if the native Soap extension wasn't loaded, which is why I didn't catch that on my development machine.
Ref: http://code.google.com/p/nusoap-for-php5/issues/detail?id=2
我不怪你,PHP 内置的soap 库是完整的,而且完全令人尴尬,特别是与Python Web 服务相比。
一种选择是在编译时删除扩展:
另一种选择是在 nuSoap 中重命名soap-client。 Notepad++ 的搜索和替换效果很好,但您实际上不必这样做。
I don't blame you, the built in soap library for PHP is complete and total embarrassment, especially when compared to python web services.
One option is to remove the extension at compile time:
Another option is to rename soap-client in nuSoap. Notepad++'s search and replace works well, but you really shouldn't have to do this.