webservice通过soap协议出现不能加载wsdl文件解决办法

PHP在用SOAP协议做接口的时候,经常会碰到如下问题,不是不成功,而是偶尔不成功,实在让人费解!


ERR: SOAP-ERROR: Parsing WSDL: Couldn‘t load from ‘http://www.xxxxx.com/member/member_sync.php?wsdl‘ : failed to load external entity "http://www.xxxxx.com/member/member_sync.php?wsdl"


查找日志发现:

NOTIC: [2] SoapClient::SoapClient(): I/O warning : failed to load external entity "http://www.xxxxx.com/member/member_sync.php?wsdl" /home/wwwroot/default/xxxxx.com/App/Modules/Admin/Action/OrderAction.class.php 第 112 行.


网上查找很多资料,有开启selinux、关闭soap缓存、开启openssl等等答案,但尝试过后都不尽人意,现终极解决办法:

只需把php的客户端SoapClient的wsdl模式修改为non-wsdl模式,即可解决!


wsdl模式:

<?php

$url = "http://xxxxx.org/member/member_sync.php?wsdl";

$client = new SoapClient ( $url );


$arr = array (

‘username‘ => ‘test123‘, 

‘company‘ => ‘深圳市xxxxx科技有限公司‘, 

‘password‘ => md5 ( md5 ( "test123" ) ), 

‘encrypt_code‘ => ‘thisisencryptcode‘ ); //加密串,必须

$result = $client->common_func ( ‘sync_member‘, json_encode ( $arr ) );

var_dump ( $result );

?>


non-wsdl模式:

<?php

$client = new SoapClient(null,array(‘location‘=>‘http://www.zgzszj.com/member/member_sync.php‘,uri => ‘member_sync.php‘));


$arr = array (

‘username‘ => ‘test123‘, 

‘company‘ => ‘深圳市xxxxx科技有限公司‘, 

‘password‘ => md5 ( md5 ( "test123" ) ), 

‘encrypt_code‘ => ‘thisisencryptcode‘ ); //加密串,必须

$result = $client->common_func ( ‘sync_member‘, json_encode ( $arr ) );

var_dump ( $result );

?>





webservice通过soap协议出现不能加载wsdl文件解决办法,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。