2012-04-17 14 views
0

zendフレームワークで新しいタイプを追加することはできません。私が試したこのphpのzendフレームワークでカスタムタイプを追加しますか?

$server = new Zend_Soap_Server('http://localhost/CycleProphet/amember/ws/index/wsdl'); 

$server->addComplexType('AMemberUser'); 

class AMemberUser 
{ 
    public $UserId; 
    public $FirstName; 
    public $LastName; 
}  

タイプが追加されましたが、それは空です。私はこの記事をhttp://framework.zend.com/manual/en/zend.soap.wsdl.html#zend.soap.wsdl.types.add_complexと使いますが、それは私を助けません。

+0

なぜマイナスですか?この必要がある場合、私は何らかの情報を提供することができます。 –

+4

投票が行われたときにコメントを残してください! – Songo

+1

私はSongoに同意します。理由が分かれば、著者は未来を知るだろう。 – Karol

答えて

1

あなたのコメントの後、私は私の答えを書き直して、あなたにWSDLといくつかのソリューションを提供することを決定した:

<?php 

require_once('Zend/Soap/Client.php'); 
require_once('Zend/Soap/Server.php'); 
require_once('Zend/Soap/Wsdl.php'); 
require_once('Zend/Soap/AutoDiscover.php'); 

class SoapController extends AppController 
{  
    public function zendclientAction() 
    { 
     $_client = new Zend_Soap_Client('http://localhost/php5_testapp/soap/zendserver?wsdl'); 
     $_ret = $_client->addNumbers(3, 5); 

     echo('<pre>'); 
     var_dump($_ret); 
     echo('<pre>'); 
     die(); 
    } 

    public function zendserverAction() 
    { 
     if(isset($_GET['wsdl'])) { 
      $_autod = new Zend_Soap_AutoDiscover(); 
      $_autod->setClass('MySoapServerClass'); 
      $_autod->handle(); 
     } 
     else { 
      $_server = new Zend_Soap_Server('http://localhost/php5_testapp/soap/zendserver?wsdl'); 
      $_server->setClass("MySoapServerClass"); 
      $_server->handle(); 
     } 

     exit; 
    } 
} 

/** 
* My Soap Server Class 
*/ 
class MySoapServerClass { 

    /** 
    * This method adds two numbers 
    * 
    * @param integer $a 
    * @param integer $b 
    * @return string 
    */ 
    public function addNumbers($a, $b) { 

     return 'Outcome is: ' . ($a + $b); 
    } 
} 

今あなたが好きなクラスを追加することができます!しかし、覚えておいてください - あなたのクラスはWSDLファイルがこれに基づいて生成されるので、よく文書化されるべきです。

希望すると助かります!

+0

いいえ、Carlos。関数addNumberは文字列を返しますが、私はカスタム型を追加してwsdlの説明に追加します。 –

+0

こんにちは、私は私の答えを書き返しました、今私はそれをよく理解しています。これをチェックしてください。 – Karol

関連する問題