PHP 肥皂问题

PHP soap issues

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

OS : 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();
}

soap 客户端

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>';
  }

2 个可能的原因 -

  1. 您正在回显代码中的某些内容,或者正在打印空白字符或尾随换行符。

  2. php 中的服务器 SOAP 文件使用 BOM 编码 utf8,导致 apache 在 xml 响应之前发回 BOM 标记(3 个字节)。使用不带 BOM 标记的 utf8 编码您的 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 );
}