我在 ubuntu 12.04 下工作。
我有一个经典的本地主机设置。 Apache + mysql + php
file_get_contents 在外部 url 上失败,但适用于本地文件或“localhost”
file_get_contents('http://google.com');
PHP Warning: file_get_contents(http://google.com): failed to open stream: HTTP request failed!
soapClient 在外部 url 上失败,但适用于本地文件或“localhost”
$wsdl = "http://test.webservices.delijn.be/wsrise/services/travel/WEB-INF/wsdl/RiseWebservices.wsdl";
$client = new SoapClient($wsdl,
array(
'trace' => true,
'exceptions' => true,
'soap_version' => SOAP_1_1,
'connection_timeout' => 600,
'compression' => SOAP_COMPRESSION_ACCEPT ,
'encoding'=> 'UTF-8', //ISO-8859-1',
//'cache_wsdl' => WSDL_CACHE_BOTH,
//'host' => "localhost",
//'proxy_host' => "localhost",
//'proxy_port' => 8080,
));
SOAP-ERROR: Parsing WSDL: Couldn't load from
'http://test.webservices.delijn.be/wsrise/services/travel/WEB-INF/wsdl/RiseWebservices.wsdl' : failed to load external entity "http://test.webservices.delijn.be/wsrise/services/travel/WEB-INF/wsdl/RiseWebservices.wsdl"
allow_url_fopen 和 allow_include_url 在 phpinfo() 中打开(在/etc/php5/apache2/php.ini 中设置)
防火墙被禁用
apparmor 被禁用
安装了 suhosin 补丁,我在 php.ini 中将 suhosin.simulation 设置为 true
该代码在我的生产和登台服务器上运行良好
我没有想法,没有找到可以检查问题的有趣日志或命令:'(
谢谢你的帮助 !
最佳答案
好的 !我找到了让它工作的方法。
安装 de suhosin-php 包以便能够使用模块 suhosin。
在/etc/php5/con.d/suhosin.conf 中将 suhosin.simulation 指令设置为 on
sudo 服务 apache2 重启
SOAP 调用仍然非常缓慢,但现在可以正常工作
谢谢你的帮助 !
关于php - 从本地 LAMP 访问 SoapClient 和 file_get_contents,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11245294/