1

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.

shasi kanth
  • 6,987
  • 24
  • 106
  • 158
  • Define your own ComplexType with these parameters as properties and make this method accept only one argument of this object. – dev-null-dweller Dec 26 '13 at 11:06
  • @dev-null-dweller Well, i saw that the WSDL is using some XSD files that define the complex types with several parameters. Hope i can pass these complex type objects as parameters to my method. – shasi kanth Dec 27 '13 at 08:31

2 Answers2

2

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' ....);
Dmitriy.Net
  • 1,476
  • 13
  • 24
  • But as i mentioned, it is the Client who is calling my SOAP Server method. So i am not sure how he will pass arguments to my method. I am supposed to define the arguments for my method and process them. – shasi kanth Dec 26 '13 at 11:17
  • As you have said: "i would like to receive all parameters in my Server method, as an array or object." - method func_get_args() gets incoming parameters as array. After that you may to process them as you like – Dmitriy.Net Dec 26 '13 at 12:06
  • But without even defining any arguments to my method, is it possible to get all the incoming parameters? – shasi kanth Dec 26 '13 at 12:08
  • If I understand the last question, this function gets all yours incoming parameters. I'm add example – Dmitriy.Net Dec 26 '13 at 12:11
0

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

shasi kanth
  • 6,987
  • 24
  • 106
  • 158