php 未捕获的 SoapFault 异常:[HTTP] 获取 http 标头时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/920646/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uncaught SoapFault exception: [HTTP] Error Fetching http headers
提问by Remy
I'm trying to create a soap connection to Magento's web services, however I'm getting an error when I try and create an instance of the soap client class. I can view the wsdl file in firefox without problems and I can watch php make the request for the wsdl in apaches logs but it still fails. Nusoap can connect.
我正在尝试创建到 Magento 的 Web 服务的soap 连接,但是当我尝试创建soap 客户端类的实例时出现错误。我可以在 Firefox 中查看 wsdl 文件而没有问题,我可以看到 php 在 apaches 日志中发出对 wsdl 的请求,但它仍然失败。Nusoap可以连接。
$proxy = new SoapClient('someaddress?wsdl');
The error is
错误是
<b>Fatal error</b>: Uncaught SoapFault exception: [HTTP] Error Fetching http headers in /home/sites/xxx/xxx_main/system/application/views/contentpage_templates/gift_service.php:29
Stack trace:
[internal function]: SoapClient->__doRequest('<?xml version="...', 'http://cornishw...', 'urn:Mage_Api_Mo...', 1, 0)
[internal function]: SoapClient->__call('call', Array)
/home/sites/xxx/xxx_main/system/application/views/contentpage_templates/gift_service.php(29): SoapClient->call(NULL, 'catalog_categor...', 5, 'giftshop')
/home/sites/xxx/xxx_main/system/application/libraries/MY_Loader.php(586): include('/home/sites/cor...')
/home/sites/xxx/xxx_main/system/application/libraries/MY_Loader.php(228): MY_Loader->_ci_load(Array, '')
/home/sites/xxx/xxx_main/system/application/modules/contentpage/controllers/contentpage.php(44): MY_Loader->view('contentpage_tem...', false, true)
[internal function]: Contentpage->index()
/home/sites/xxx in <b>/home/sites/xxx/xxx_main/system/application/views/contentpage_templates/gift_service.php</b> on line <b>29</b>
Thanks
谢谢
回答by
Try to set :
尝试设置:
default_socket_timeout = 120
in your php.inifile.
在您的php.ini文件中。
回答by hegemon
Did you try adding
您是否尝试添加
'trace'=>1,
to SoapClient creation parameters and then:
到 SoapClient 创建参数,然后:
var_dump($client->__getLastRequest());
var_dump($client->__getLastResponse());
to see what is going on?
看看是怎么回事?
回答by David Hurst
This error can appear on the client if there is a problem on the server side. For example, if the SOAP server is a PHP script with a parse error, the client will fail with this message.
如果服务器端出现问题,则客户端上可能会出现此错误。例如,如果 SOAP 服务器是一个带有解析错误的 PHP 脚本,则客户端将失败并显示此消息。
If you are in control of the server, tail your Apache error_log on the machine that hosts the SOAP server. On CentOS you will find this in /var/log/httpd/error_log, so the command is:
如果您可以控制服务器,请在托管 SOAP 服务器的机器上跟踪您的 Apache error_log。在 CentOS 上,你会在 /var/log/httpd/error_log 中找到它,所以命令是:
tail -f /var/log/httpd/error_log
tail -f /var/log/httpd/error_log
Now refresh the client and watch for the error message. Any PHP errors with the server script will be shown.
现在刷新客户端并观察错误消息。将显示服务器脚本的任何 PHP 错误。
Hope that helps someone.
希望能帮助某人。
回答by Rahul Prasad
I faced the same problem.
I was running It as CLI. So PHP was always running and it had to make soap call again and again after some interval.
The mistake I did was using singleton pattern for this. I thought use of singleton will cause performance boost but inturn I got
我遇到了同样的问题。
我将它作为 CLI 运行。所以 PHP 一直在运行,它不得不在一段时间后一次又一次地调用肥皂。
我犯的错误是为此使用了单例模式。我认为使用单例会提高性能,但反过来我得到了
Error Fetching http headers in ...
I fixed it by creating new saop object for each call.
我通过为每次调用创建新的 saop 对象来修复它。
回答by Posto
I am not about your PHP configuration but until PHP 5.2.6 , PHP does have some problem with SOAP client :
我不是关于你的 PHP 配置,但在 PHP 5.2.6 之前,PHP 确实有一些 SOAP 客户端问题:
Bug #41983 - Error Fetching http headers


回答by Michael Mussulis
If this is a Magento related problem, you should turn off automatic re-indexing as this could be causing the socket to timeout (or expire). You can turn it back on once the script has finished its tasks. Increasing the default socket timeout in php.ini is also a good idea.
如果这是 Magento 相关问题,您应该关闭自动重新索引,因为这可能会导致套接字超时(或过期)。脚本完成其任务后,您可以将其重新打开。增加 php.ini 中的默认套接字超时也是一个好主意。
回答by Sanjay Mohnani
I faced same problem and tried all the above solution. Sadly nothing work.
我遇到了同样的问题并尝试了上述所有解决方案。可悲的是没有任何作用。
- Socket Timeout (Not worked)
- User Agent (Not Worked)
- SoapClient configuration, cache_wsdland Keep-Aliveetc..
- 套接字超时(无效)
- 用户代理(未工作)
- SoapClient 配置,cache_wsdl和Keep-Alive等。
This whole game of headers that we are passing. I solved my problem with adding the compressionheader property. This actually require when you are expecting response in gzipcompressed format.
我们正在传递的整个头球比赛。我通过添加压缩标头属性解决了我的问题。当您期望gzip压缩格式的响应时,这实际上需要。
//set the Headers of Soap Client.
$client = new SoapClient($wsdlUrl, array(
'trace' => true,
'keep_alive' => true,
'connection_timeout' => 5000,
'cache_wsdl' => WSDL_CACHE_NONE,
'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | SOAP_COMPRESSION_DEFLATE,
));
Hope it helps.
希望能帮助到你。
Good luck.
祝你好运。
回答by Shahzeb chohan
Please update your php.ini with
请更新您的 php.ini
default_socket_timeout = 120
You can create your own php.ini if php is installed a CGI instead of a Apache module
如果 php 安装的是 CGI 而不是 Apache 模块,您可以创建自己的 php.ini
回答by saintsjd
In my apache error log, I saw:
在我的 apache 错误日志中,我看到:
[Tue Feb 16 14:55:02 2010] [notice] child pid 9985 exit signal File size limit exceeded (25)
So I, removed all the contents of my largest log file 2.1GB /var/log/system.log. Now everything works.
所以我删除了我最大的日志文件 2.1GB /var/log/system.log 的所有内容。现在一切正常。
回答by obiyoda
There is an issue in php version less than 5.2.6. You may need to upgrade the version of php.
低于 5.2.6 的 php 版本存在问题。您可能需要升级 php 版本。

