0

我无法使用 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,但这对我没有帮助。

4

1 回答 1

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 文件是基于此生成的。

希望能帮助到你!

于 2012-04-17T07:44:55.400 回答