logo       

addComplexType problems with an associative array: msg#00108

php.nusoap.general

Subject: addComplexType problems with an associative array

Hello,

I have a problem creating my WSDL file since days.
I searched at Google and this mailing list archive but could'nt solve my problem.

The problem is that I don't know how to send an associative array as the response to the client.

This is my server:

/*----------------------------------------------------------------------*/

$server = new soap_server();

$server->configureWSDL('Nameserver', $NAMESPACE);
$server->wsdl->schemaTargetNamespace = $NAMESPACE;

$server->wsdl->addComplexType(
'ArrayOf_xsd_string',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),

array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]')),'xsd:string'
);

function CheckUser($userid,$password,$userdata) {
// some checks here
return array("ret_code"=>"200","ret_message"="User Okay.");
}

$server->register('CheckUser', // method name
array( 'userid'=>'xsd:int',
'password'=>'xsd:string',
'userdata'=>'tns:ArrayOf_xsd_string'
), // input parameters
array('return' => 'tns:ArrayOf_xsd_string'), // output parameters
$NAMESPACE, // namespace
'', // soapaction
'rpc', // style
'encoded', // use
'Checks the nameserver configuration for a domain name' // documentation
);

// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

/*----------------------------------------------------------------------*/

This is my client:

/*----------------------------------------------------------------------*/

$client = new soapclient('http://myserver/server.php?wsdl', true);

$result = $client->call('CheckUser',
array( 'userid' => 123,
'password' => "secret",
'userdata' => array("Key1"=>"Value1","Key2"=>"Value2")
)
);

print_r($result);

/*----------------------------------------------------------------------*/

The result currently looks like:

Array
(
[0] => 200
[1] => User Okay.
)

But I need it like this:

Array
(
[ret_code] => 200
[ret_message] => User Okay.
)

May I use "apachesoap:Map" for this? I found this in the nusoap class source code. But is there some documentation for this?

What changes are needed to let asociative arrays work with WSDL?

Thanks a lot and best regards,

Mario


-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise