php - 从本地 LAMP 访问 SoapClient 和 file_get_contents

标签 php apache ubuntu soap virtualhost

我在 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/

相关文章:

linux - 以编程方式为新用户克隆/etc/skel

mongodb - 如何在ubuntu中安装mongodb-c驱动并在coturn服务器中使用

php - 在 mysql 和 php 中合并两个表的更有效方法?

apache - 禁止访问您无权访问/在此服务器上

apache - WAMP 2.5 (Apache 2.4.9) 允许从 LAN 上的所有计算机进行访问

apache - .htaccess 使用 request_uri 和 query_string 中的参数

python - 如何确定是否安装了 iODBC、unixODBC(或两者均未安装)?

php - jQuery 将表单选择值添加到远程文件的 $_GET 值

php - 根据先前表单中选定的 list 创建新表单

php - 使用nuxtjs登录laravel sanctum后出现401(未经身份验证)错误