【发布时间】:2012-06-30 00:16:47
【问题描述】:
我在 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
代码在我的生产和登台服务器上运行良好
我没有想法,没有找到可以检查问题的有趣日志或命令:'(
感谢您的帮助!
【问题讨论】:
-
@Quasdunk 数组中的尾随逗号不会引发语法错误,并且有时是某些编码标准所要求的。
-
您是否尝试过从 shell 访问这些站点?就做
curl http://test.webservices.delijn.be/wsrise/services/travel/WEB-INF/wsdl/RiseWebservices.wsdl -
@MikeB 什么.... 我的一生都是谎言:-D 感谢您的评论,我并没有真正意识到这一点! (不过,如果只有逗号,它会抛出异常。)
-
curl 和 GET 在 shell 中效果很好。
标签: php apache ubuntu soap virtualhost