Drupal 7-soap
这是我在错误日志中获取的错误,当我试图打印时 test.wsdl 文件
SoapFault: looks like we got no XML document in SoapClient->__call()
我不知道错误是什么
我的项目环境
PHP:5.4.11
MySQL:5.5.27 Apache:2.2.3
操作系统:CentOS 5.8
代码信息
function ai_server() {
ini_set('soap.wsdl_cache_ttl', 0);
$server = new SoapServer(file_create_url(variable_get('app_integration_wsdl')), array("trace" => 1, "exceptions" => 0));
$server->addFunction('getData');
$server->addFunction('getId');
$server->addFunction('getInfo');
$server->addFunction('getrightsInfo');
$server->addFunction('updateInfo');
$server->addFunction('resetAppHistory');
//$server->addFunction('resetAppId');
$server->handle();
}
肥皂客户端
function ai_sync_test() {
ini_set('soap.wsdl_cache_ttl', 0);
//
// ---------------------------------------------------------------- basic tests
//
// is settings file accessible
$settings_file = variable_get('app_integration_settings');
require_once($settings_file);
$settings_output = is_readable($settings_file) ? 'Ok! Settings file is readable.' : 'Error! Not readable or accessible.';
// is wsdl file accessible
$wsdl_file = variable_get('app_integration_wsdl');
$wsdl_output = is_readable($wsdl_file) ? 'Ok! WSDL file is readable. ' . l('Open it. ', $wsdl_file, array('attributes' => array('target' => '_blank'))) : 'Error! Not readable or accessible. ';
$wsdl_output .= 'You need to define domain name in it into this sections (at the bottom of app_integration.wsdl file): ';
$wsdl_output .= htmlentities('<soap:address location="http://YOUR_DOMAIN_HERE/app_integration/server"/>');
// methods, which integration service is provide
$client = new SoapClient($wsdl_file, array("trace" => 1, "exceptions" => 0));
$methods = $client->__getFunctions();
$methods_output = '';
foreach ($methods as $method) {
$methods_output .= '<li>' . $method . '</li>';
}
答案 0 :(得分:0)
2个可能的原因 -
您正在回显代码中的某些内容,或者正在打印空白字符或尾随换行符。
php中的服务器SOAP文件使用BOM编码utf8,导致apache在xml响应之前发回BOM标记(3个字节)。使用utf8 WITH OUT BOM标记对您的php文件soap服务器进行编码。
function strip_bom($str){
return preg_replace( '/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/', "", $str );
}