2011-12-30 17 views
0

アプリケーション間でデータを同期できるようにIpadアプリケーションのWebサービスを作成したいウェブサーバーで私を案内してください。wsdl解析エラー、外部エンティティ "http:// localhost:10088/SoapService/public/testService.php?wsdl"の読み込みに失敗しました

この単純なPHPスクリプトをテストしてシンプルなWebサービスを作成しようとしていますが、このエラーが発生しています。間違っていますか?このコードを超える場合に他の誰かつまずくで

<?php 

// Define path to application directory 
defined('APPLICATION_PATH') 
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application')); 

// Define application environment 
defined('APPLICATION_ENV') 
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production')); 

// Ensure library/ is on include_path 
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'), 
    get_include_path(), 
))); 

/** Zend_Application */ 
require_once 'Zend/Application.php'; 

// Create application, bootstrap, and run 
$application = new Zend_Application(
    APPLICATION_ENV, 
    APPLICATION_PATH . '/configs/application.ini' 
); 

require_once 'Zend/Loader/Autoloader.php'; 
require_once('Zend/Soap/AutoDiscover.php'); 
require_once('Zend/Soap/Server.php'); 
require_once('Zend/Soap/Client.php'); 
?> 
<?php 

class Login { 

    /** 
    * Add method 
    * 
    * @param Int $param1 
    * @param Int $param2 
    * @return Int 
    */ 
    public function math_add($param1, $param2) { 
     return $param1+$param2; 
    } 

    /** 
    * Logical not method 
    * 
    * @param boolean $param1 
    * @return boolean 
    */ 
    public function logical_not($param1) { 
     return !$param1; 
    } 

    /** 
    * Simple array sort 
    * 
    * @param Array $array 
    * @return Array 
    */ 
    public function simple_sort($array) { 
     asort($array); 
     return $array; 
    } 
} 

class LoginController 
{ 
    private $_WSDL_URI = "http://localhost:10088/SoapService/public/index.php?wsdl"; 

    public function init() 
    { 
    } 

    public function indexAction() 
    { 

     $this->hadleWSDL(); 

     if(isset($_GET['wsdl'])) { 
      //return the WSDL 
      $this->hadleWSDL(); 
     } else { 
      //handle SOAP request 
      $this->handleSOAP(); 
     } 
    } 

    private function hadleWSDL() { 
     $autodiscover = new Zend_Soap_AutoDiscover(); 
     $autodiscover->setClass('Login'); 
     $autodiscover->handle(); 
    } 

    private function handleSOAP() { 
     $soap = new Zend_Soap_Server($this->_WSDL_URI); 
     $soap->setClass('Login'); 
     $soap->handle(); 
    } 

    public function clientAction() { 
     $client = new Zend_Soap_Client($this->_WSDL_URI); 

     echo $client->math_add(11, 55); 
     echo $client->logical_not(true); 
     echo $client->simple_sort(array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple")); 

    } 

} 

$soapController = new LoginController(); 
$soapController->init(); 
$soapController->indexAction(); 
$soapController->clientAction(); 

?> 

答えて

1

、私が行ったよう... は私がうまく動作するように、この例を手に入れました。最初は「間違ったバージョン」の例外がありました。コード内で変更する必要があるのは、URLをSoap Serverに追加することだけです。

私は$autodiscover->setUri("http://some/path/to/soapserver/");を追加しました。うまく動作します。

関連する問題