【问题标题】:Access SoapClient and file_get_contents from local LAMP从本地 LAMP 访问 SoapClient 和 file_get_contents
【发布时间】: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


【解决方案1】:

好的!我找到了让它工作的方法。

安装 de suhosin-php 包以便能够使用模块 suhosin。 在 /etc/php5/con.d/suhosin.conf 中将 suhosin.simulation 指令设置为 on sudo service apache2 重启

Soap 调用仍然非常慢,但现在可以正常工作

感谢您的帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-30
    • 1970-01-01
    • 2021-04-17
    • 2014-09-19
    相关资源
    最近更新 更多