Question

I am currently using the following in my nusoap server file:

$server->wsdl->addComplexType(
    'member',
    'complexType',
    'struct',
    'all',
    '',
    array(
        'ID' => array('MemberInfo' => 'ID', 'type' => 'xsd:int'),
        'FIRST_NAME' => array('MemberInfo' => 'FIRST_NAME', 'type' => 'xsd:string'),
        'LAST_NAME' => array('MemberInfo' => 'LAST_NAME', 'type' => 'xsd:string')
)

Which returns:

<ID xsi:type="xsd:int">1</ID>
<FIRST_NAME xsi:type="xsd:string">John</FIRST_NAME>
<LAST_NAME xsi:type="xsd:string">Doe</LAST_NAME>

How can I modify this to receive the following output:

<ID xsi:type="xsd:int">1</ID>
<NAME>
            <FIRST_NAME xsi:type="xsd:string">John</FIRST_NAME>
            <LAST_NAME xsi:type="xsd:string">Doe</LAST_NAME>
</NAME>
Was it helpful?

Solution

Turns out the way to accomplish this was to include a single entry in my response datatype with an array for the wrapper:

'ID' => array('MemberInfo' => 'ID', 'type' => 'xsd:int'),    
'NAME' => array('NAME' => array('NAME', 'type' => 'xsd:string'))

And then of course store that name info in a sub array

return array (    
'ID' =>  $user_info->ID,
'NAME' => array(                            
        'FIRST_NAME' => $user_info->first_name,
        'LAST_NAME' => $user_info->last_name,
    )
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top