Custom Fields on SOAP registerMember

Functionality discussions and feature requests

Moderators: hugo, alexandre, rmvanarkel

Post Reply
mraxai
Posts: 18
Joined: Mon Aug 01, 2011 2:28 pm

Custom Fields on SOAP registerMember

Post by mraxai »

Hi all,

I could really use some help on an issue I'm having with SOAP WebServices and PHP.
I wrote down a script that's capable of registering a member via the "registerMember" function, and according to the wiki, I'm trying to include some member custom fields in the process.

There's absolutely no trouble on registering a member: the whole thing go well, but it seems there's no way for me to get custom fields on registration working.
I'm sending the parameters of the function like this:

$params = new stdclass();
$params->groupId = "33";
$params->name = "Name";
$params->email = "email@email.ema";
$params->loginPassword = "secret";
$params->fields = $myfieldsarray;

The problem seems to be on the definition of $fieldsarray, wich I tried to declare this way:
$myfieldsarray = array('internalName' => 'vbfirstnamec', 'fieldId' => '91', 'displayName' => 'NomeC', 'value' => 'Andrea', 'possibleValueId' => NULL, 'hidden' => false);

I don't get any error, the registration seems to work just fine, but when I go to the member profile, the custom field just doesn't have any value.
After searching this forum I even tried this form for the array $myfieldsarray:
$myfieldsarray = array('field' => 'vbfirstnamec', 'value' => 'Andrea', 'hidden' => false);

cause in a thread I found someone sayin that was the way to pass parameters to the function, but in this case i get this error:
SoapFault exception: [ns1:invalid-parameter] Couldn't find custom field for this field: FieldValueVO [internalName=null, fieldId=null, displayName=null, value=Andrea, possibleValueId=null]
wich is why I suppose the right method to declare the custom field is the first one, according to the Wiki, also, it says you must pass a list (list? Is that intended like an actual list or an array parsed through the "list()" function?) of "registrationFieldValues", wich the model data explains to be like:

internalName (string): The custom field internal name
fieldId (number): The custom field id
displayName (string): The custom field display name
value (any): The custom field value
possibleValueId (number): The custom field possible value id
hidden (boolean): Indicates whether the given field is hidden from others

and that is what I'm sending on the first case, but it just seems to ignore my custom fields, register the user, send me back what supposed to, and when I go to the profile, the member is registered, the group and the parameters are right, but in any case, there isn't any custom field actually filled.

Any help? Any example I could use to see how a working registration with Custom Fields used is to be written?
I'm using Cyclos 3.7.1

Thanks in advance

stephendwolff
Posts: 21
Joined: Fri Sep 21, 2012 11:41 am

Re: Custom Fields on SOAP registerMember

Post by stephendwolff »

Hiya,

One thing i've found with collections of items in the cyclos web services WSDL is that they can follow a bit of an unexpected (possibly invalid) XML format:

In pseudocode you might expect something like this:

<fields>
<field>
<nameoffield>blah</nameoffield>
</field>
<field>
<nameoffield>blah2</nameoffield>
</field>
<field>
<nameoffield>blah3</nameoffield>
</field>
</fields>

However - cyclos often doesnt' wrap the collected elements in an outer one, so you'd find that the <fields> tag isn't used in the WSDL - there is a list of <field> elements, without the <fields> wrapper.

It might be worth trying to use something to send the SOAP call manually - ie 'Wireshark' on the PC? That way you can edit the XML to get it working, then make sure the PHP matches it.

Hope that helps,

Stephen
Qoin - Money that Matters
Agency for Community Currencies
Consultancy - Projects - Services - Research

http://www.qoin.org

stephendwolff
Posts: 21
Joined: Fri Sep 21, 2012 11:41 am

Re: Custom Fields on SOAP registerMember

Post by stephendwolff »

@mraxai - did you solve your issue in the end, and if so, how did you?

Thanks,

Stephen
Qoin - Money that Matters
Agency for Community Currencies
Consultancy - Projects - Services - Research

http://www.qoin.org

mraxai
Posts: 18
Joined: Mon Aug 01, 2011 2:28 pm

Re: Custom Fields on SOAP registerMember

Post by mraxai »

Hi Stephen,

yes we've solved it using your precious help together with tons of trial and error.

We also used http://www.service-repository.com/client/start to help understanding wsdl.

In the process, we've found out that some functionalities that work well in the mainweb channel seem not to work via Webservice.

We'll test more when we can and update as we proceed.

Thanks,
Giuseppe

stephendwolff
Posts: 21
Joined: Fri Sep 21, 2012 11:41 am

Re: Custom Fields on SOAP registerMember

Post by stephendwolff »

Thanks Giuseppe,

I eventually found that the naming of the custom field had changed between 3.6 and 3.7 - by comparing the WSDL - as seen by visiting:

http://<cyclos instance url>/services/members?wsdl

I'll have a look at the webservices client you mention too - i think i used 'wireshark' or something like that to do similar - ie fire a SOAP packet at a system, and view the raw response.
Qoin - Money that Matters
Agency for Community Currencies
Consultancy - Projects - Services - Research

http://www.qoin.org

Post Reply