使用 NuSoap 可以在本地计算机上运行,但不能在服务器上运行
我开发了一些代码,使用 PHP 的 NuSoap 类来调用肥皂网络服务。我使用 NuSoap 而不是 PHP 5 本机类,主要是因为我不想在将此代码安装在共享 Web 服务器上时添加额外的先决条件。该代码在我的机器上运行良好:
require DOCROOT.'modules/nbn_species_dict_sync/lib/nusoap.php';
$client = new nusoap_client('http://www.nbnws.net/ws_3_5/GatewayWebService?wsdl', true);
$query1 = '<TaxonReportingCategoryListRequest xmlns="http://www.nbnws.net/TaxonReportingCategory" registrationKey="'.$key.'"></TaxonReportingCategoryListRequest>';
$response = $client->call('GetTaxonReportingCategoryList', $query1);
当我将其放在虚拟服务器上而不是在本地运行时,最后一行仅挂起大约 10 秒,然后 PHP 崩溃了。没有引发异常,也没有 PHP 错误(我尝试使用 try..catch 和 set_error_handler 只是为了确定)。
我的第一反应是,这可能是服务器上运行的防火墙阻止传出请求,但我在其他地方成功使用 cUrl 来请求,并且我很确定这里没有运行防火墙。调用 $client->use_curl 对 NuSoap 调用没有任何影响,但它仍然不起作用。
任何可能发生这种情况的想法都将不胜感激。
I've developed some code which uses the NuSoap classes for PHP to call a soap web-service. I'm using NuSoap rather than the PHP 5 native classes mainly because I don't want to add an extra prerequisite when this code is installed on a shared web server. The code works fine on my machine:
require DOCROOT.'modules/nbn_species_dict_sync/lib/nusoap.php';
$client = new nusoap_client('http://www.nbnws.net/ws_3_5/GatewayWebService?wsdl', true);
$query1 = '<TaxonReportingCategoryListRequest xmlns="http://www.nbnws.net/TaxonReportingCategory" registrationKey="'.$key.'"></TaxonReportingCategoryListRequest>';
$response = $client->call('GetTaxonReportingCategoryList', $query1);
When I put this up on a virtual server rather than running it locally, the last line just hangs for about 10 seconds then PHP bombs out. No exception is raised and there is no PHP error (I've tried using try..catch and set_error_handler just to be sure).
My first reaction was that this might be a firewall running on the server blocking outgoing requests, but I am successfully using cUrl elsewhere for requests and I am pretty sure there is no firewall running here. Calling $client->use_curl does not make any difference to the NuSoap call though, it still does not work.
Any ideas why this might be occurring would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您没有排除故障的想法,并且假设您在 Linux 上运行,则可以使用 strace 监视系统调用。这些调用可能看起来非常神秘,但有时您可以看到它挂在哪个系统调用上,然后 Google 调用该调用以获取更多信息。
或者,如果您想跟踪脚本从执行开始到完成的整个过程并转储到输出文件:
这是一个很好的 strace 教程。
If you're out of troubleshooting ideas, and assuming you are running on Linux, you can watch the system calls by using strace. The calls can look pretty cryptic, but sometimes you can see what system call its hanging on, then Google that call for more info.
Or if you want to trace your script from start of execution to finish and dump to an output file:
Here is a good strace tutorial.
您能否确保 www-data 具有(权限)访问权限
或者您可以尝试将 nusoap 复制到另一个目录吗?
或者您可以尝试以 root 用户身份从命令提示符运行它吗?
顺便问一下,您收到什么类型的错误/警告?
Can you make sure that www-data has (permission to) access to
Or can you try to copy nusoap to another directory?
Or can you try to run it from command prompt as root user?
By the way, what kind of error/warning are you getting?