Hi,
I have some problem with SOAP user creation function.
When I look the WSDL i can see this:

<message name='user_soap_create_request'>
	<part name='account' type='xsd:array' />
</message>
<message name='user_soap_register_request'>
	<part name='account' type='xsd:array' />
</message>

So I try to call "user_soap_create_request" and feed it with an array.
My code is somethink like this:

	ini_set("soap.wsdl_cache_enabled", "0");
	$wsdl 		= 'http://localhost/services/soap/registration?wsdl';
	$endpoint 	= 'http://localhost/services/soap/registration';
	$response   = null;
	
	$soapClient = new SoapClient($wsdl, array('trace' => true, 'exceptions' => true, 'cache_wsdl' => false));
	$soapClient->__setSoapHeaders(); 
		
	$user = array(
		'name' => 'newuser',
		'mail' => 'newuser@email.com',
		'pass' => '0123456789',
	);	
	$functions = $soapClient->__getFunctions();
	try{
		$response[] = $soapClient->__soapCall('user_soap_register', $user );		
	} catch(SoapFault $e){
		print_r($e);
	}

	print_r($response);

But the service resonde me:
Service unavailable (with message)
or somethink like this when i try to use an array in a array:
Cannot use object of type stdClass as array

Some one can help me?
Thanks and sorry for my bad english.

Comments

marcus_clements’s picture

I just read your message properly!! I'll try and repeat your error later and comment.
Ignore the stuff below...

Web services run as anonymous user.
If you want your service to be able to create users you must set the Register Without Approval setting.

From services/resources/user_resource.inc line 436 : _user_resource_access()

case 'create':
    case 'register':
      if (!$user->uid && variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) != USER_REGISTER_ADMINISTRATORS_ONLY) {
        return TRUE;
      }
      else {
        return user_access('administer users');
      }

Alternatively you could create your own resource based on the services user resource and define your own access conditions.