0

I searched many examples.

But I can't find how to define nested array structure, which is not key=>value type.

client call 'hello' function with array, which is not key=>value type.

I can't touch input parameters from client side.

client side.

$client = new soapclient('http://localhost/Ex.php?wsdl', 'wsdl');

$ddd = array($id, $pw);
$parameter = array($aaa, $bbb, $ccc, $ddd);

// Call the SOAP method
$result = $client->call('hello',$parameter);

server side.

$server->wsdl->addComplexType(
    'noKey',
    'complexType',
    'struct',
    'all',
    '',
array(
    '0'=>array( 'name'=> '0', 'type' => 'xsd:string'),
    '1'=>array( 'name'=> '1', 'type' => 'xsd:string')       
    //this definition occurred error.
    )
);

$server->register('hello', // method name
    array(
        'aaa' =>'xsd:string',
        'bbb' =>'xsd:string',
        'ccc' =>'xsd:string',
        'ddd' =>'tns:noKey'
    ), // input parameters

    array('return' => 'xsd:string'), // output parameters
    'urn:Exwsdl', // namespace
    false, // soapaction
    'rpc', // style
    'encoded', // use
    'Greet a person entering the sweepstakes' // documentation
 );

 function hello($aaa, $bbb, $ccc, $ddd) {
     return $aaa.", ".$bbb.", ".$ccc.", ".$ddd[0].", ".$ddd[1];
 }

error

Array
(
    [faultcode] => SOAP-ENV:Client
    [faultactor] => 
    [faultstring] => error in msg parsing:
    XML error parsing SOAP payload on line 1: XML_ERR_NAME_REQUIRED
    [detail] => 
)

help me T.T

Alice Kim
  • 1
  • 1

1 Answers1

0

Try don't using numbers as name for your array-elements in the definition of your complex type.

Following version of your code works fine for me:

$server->register('hello', // method name
    array(
        'aaa' =>'xsd:string',
        'bbb' =>'xsd:string',
        'ccc' =>'xsd:string',
        'ddd' =>'tns:noKey'
    ), // input parameters

    array('return' => 'xsd:string'), // output parameters
    'urn:Exwsdl', // namespace
    false, // soapaction
    'rpc', // style
    'encoded', // use
    'Greet a person entering the sweepstakes' // documentation
);

$server->wsdl->addComplexType(
    'noKey',
    'complexType',
    'struct',
    'all',
    '',
    array(
        'forename'=>array( 'name'=> 'forename', 'type' => 'xsd:string'),
        'surname'=>array( 'name'=> 'surname', 'type' => 'xsd:string')
        )
);

function hello($aaa, $bbb, $ccc, $ddd) {
    return $aaa.", ".$bbb.", ".$ccc.", ".$ddd['forename'].", ".$ddd['surname'];
}
OrcHound
  • 188
  • 1
  • 7