'calling server using nusoap with complextype

i am calling a client in a browser, and sending an array of arrays as a parameter to a server function, it return mein first key value pair that fine, but it only send me key of the second array not its value, please help me out.

Client

<?php 

    require_once("nuSOAP/lib/nusoap.php");


    $id = array('ID'=>'1234','type' => 'int');

    $MyComplexType = array(
                        'ID'=> $id,
                        'YourName' =>array('YourName' => '123','type' => 'string')
                        );


    //Create object that referer a web services
    $client = new soapclient('http://localhost/server/server2.php');
    //Call a function at server and send parameters too
    $response = $client->call('HelloComplexWorld',$MyComplexType);
    //Process result
    if($client->fault)
    {
      echo "FAULT: <p>Code: (".$client->faultcode."</p>";
      echo "String: ".$client->faultstring;
    }
    else
    {
            echo"<pre>";
            print_r($response);
            echo "</pre>";
            exit();
    }

 ?>

Server

<?php 

    require_once("nuSOAP/lib/nusoap.php");
    $namespace = "http://localhost/server/server2.php";

    // create a new soap server
    $server = new soap_server();

    // configure our WSDL
    $server->configureWSDL("HelloExample");

    // set our namespace
    $server->wsdl->schemaTargetNamespace = $namespace;

    //Register a method that has parameters and return types
    $server->register(
    // method name:
    'HelloWorld',
    // parameter list:
    array('name'=>'xsd:string'),
    // return value(s):
    array('return'=>'xsd:string'),
    // namespace:
    $namespace,
    // soapaction: (use default)
    false,
    // style: rpc or document
    'rpc',
    // use: encoded or literal
    'encoded',
    // description: documentation for the method
    'Simple Hello World Method');

    //Create a complex type
    $server->wsdl->addComplexType(
        'MyComplexType',
        'complexType',
        'struct',
        'all',
        '',
    array( 
        'ID' => array(
            'name' => 'ID',
            'type' => 'xsd:int'
            ),
        'YourName' => array(
            'name' => 'YourName',
            'type' => 'xsd:string'
            )

        )
    );

    //Register our method using the complex type
    $server->register(
    // method name:
    'HelloComplexWorld',
    // parameter list:
    array('name'=>'tns:MyComplexType'),
    // return value(s):
    array('return'=>'tns:MyComplexType'),
    // namespace:
    $namespace,
    // soapaction: (use default)
    false,
    // style: rpc or document
    'rpc',
    // use: encoded or literal
    'encoded',
    // description: documentation for the method
    'Complex Hello World Method');

    //Our Simple method
    function HelloWorld($name)
    {
    return "Hello " . $name;
    }

    //Our complex method
    function HelloComplexWorld($mycomplextype)
    {

    return $mycomplextype;
    }

    // Get our posted data if the service is being consumed
    // otherwise leave this data blank.
    $POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';

    // pass our posted data (or nothing) to the soap service
    $server->service($POST_DATA);
    exit();


 ?>

OUTPUT

Array
(
    [ID] => 1234
    [YourName] => 
)


Solution 1:[1]

Got it right using the following as parameter,

    $MyComplexType = array('ID' => $id ,'YourName' => "Jon Postel");

This gives

Array
  (
    [ID] => 1234
    [YourName] => "Jon Postel"
 )

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Anish