PHP SOAP Server method receive a set of parameters

本小妞迷上赌 提交于 2019-12-11 06:15:57

问题


I have setup a SOAP Server with php.

The problem is that, as per the WSDL, the client which calls the server method, is supposed to pass a set of parameters (more than 50). I got to know this from SOAP UI.

But how do i handle all those parameters in my Server method? Should i go on and declare each and every parameter for my Server method, as below?

public function addMessage($a, $b, $c, $d, .................) {

}

But I hope there must be a simpler approach to this. Preferably, i would like to receive all parameters in my Server method, as an array or object.

UPDATE: I am using Zend_Soap_Server. Do i need to define any complex types, for handling input parameters? As i see, the WSDL defines few complex types.


回答1:


Try to use http://www.php.net/manual/en/function.func-get-args.php

public function addMessage() {
    $args = func_get_args();

    foreach($args as $argument)
    {
         # processing 
         $this->do_process($argument);
    }
    var_dump($args);
}

Call

$this->addMessage('a', 'b', 'c', 'd', ....);

and function will return

array(1 => 'a', 2 => 'b', 3 => 'c', 4 => 'd' ....);



回答2:


Well, i could finally receive the parameters as objects in my method. These objects were already defined as complex types in the XSD files.



来源:https://stackoverflow.com/questions/20783629/php-soap-server-method-receive-a-set-of-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!