[英]Error Fetching http headers SOAP
i have a problem with SOAP, havent found a real answer.我对 SOAP 有问题,还没有找到真正的答案。
try {
$objResponse = $objSoapClient->$strMethod($objMethod->getSoapRequest());
}
catch (SoapFault $e) {
GlobalLogState::write("exception with code(".$e->getCode()."): \n".$e->getMessage());
}
This is my simple SOAP request in try catch block.这是我在 try catch 块中的简单 SOAP 请求。
I'm getting a SoapFault Exception:我收到一个 SoapFault 异常:
Error Fetching http headers
What is the reason of that?那是什么原因呢?
The configuration that has worked for me was defining at my php script the following parameters:对我有用的配置在我的 php 脚本中定义了以下参数:
ini_set('default_socket_timeout', 5000);
$client = new \SoapClient($url,array(
'trace' =>true,
'connection_timeout' => 5000,
'cache_wsdl' => WSDL_CACHE_NONE,
'keep_alive' => false,
));
Please, comment.请给出意见。
The most important parameter definition, as per my experience with this issue was ini_set('default_socket_timeout', 5000);根据我对这个问题的经验,最重要的参数定义是 ini_set('default_socket_timeout', 5000);
During my tests I have defined the default_socket_timeout to 5 seconds and the error 'Error Fetching http headers' was raised instantaneously.在我的测试中,我将 default_socket_timeout 定义为 5 秒,并且立即引发了错误“错误获取 http 标头”。
I hope it helps you.我希望它能帮助你。
To fix this error, we can increase the either increase the socket timeout default_socket_time
in php.ini
or add the connection_timeout
parameter in the parameter array passed to the constructor of the SoapClient.为了修复这个错误,我们可以增加要么增加
php.ini
的套接字超时default_socket_time
要么在传递给 SoapClient 的构造函数的参数数组中添加connection_timeout
参数。
These parameter are in seconds .这些参数以秒为单位。
In php.ini在 php.ini
default_socket_timeout = 120
Alternatively, you can change from code或者,您可以从代码更改
ini_set('default_socket_timeout', 120);
Note: The default socket timeout in php is 60 seconds.注意:php 中默认的套接字超时时间为 60 秒。
connection_timeout
parameter in SoapClient constructor connection_timeout
参数$client = new SoapClient($wsdl, array('connection_timeout' => 120));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.