SOAP GetAttributeValuesByName potential bug

Hi,


I've spent the last 1.5 days trying to use the GetAttributeValuesByName function in the SOAP Server. I have tested on 3.26.2 and 3.28.5 (and I've checked the code in 3.28.6 - it is identical).



It appears that the GetAttributeValuesByName function in soap_api_asset_service.inc calls the getAttributeValuesByName function in asset_manager.inc. This second function expects an array of asset ids, yet the first function passes only a string. The function then fails to return a value but does not error out (the second function contains the line

    if (empty($assetids)) return Array(); 
).



Attempts to send an array of arrays to the initial function fail.



I have tested this in both Perl and PHP. I've been able to use both languages to interact successfully with the Server.



If I modify the following line in soap_api_asset_service.inc


    $attribute_values	= $GLOBALS['SQ_SYSTEM']->am->getAttributeValuesByName($attr_name, $type_code, $assetids);


to

    $attribute_values	= $GLOBALS['SQ_SYSTEM']->am->getAttributeValuesByName($attr_name, $type_code, Array($assetids));


then it works.

It has been some time since I've touched PHP so I may have missed something. Have I found a bug or am I doing something wrong with my SOAP requests?

Thanks.

Possibly something wrong with your SOAP requests, I tried this php code and got a valid response:

    $options = array(
            'login'         => "USERNAME",
            'password'      => "PASSWORD",
            'soap_version'  => SOAP_1_2,
            'exceptions'    => TRUE,
            'trace'         => 1,
            'cache_wsdl'    => WSDL_CACHE_NONE,
           );  
    
    $request = array(
            'AssetIDs'      => array('79','80','100'),
            'AttributeName' => 'name',
            'TypeCode'      => 'page_standard',
           );  
    try {
    $client   = new SoapClient("http://www.example.com/_web_services/soap?wsdl", $options);
    $response = $client->getAttributeValuesByName($request);
    } catch (Exception $e) {
    echo $e->getMessage()."\n";
    }
    
    var_dump($response);

Thanks Ben.


Seems like if you have just one string in the array then nothing is returned. If there is there is more than one string in the array then it works. The second string can even be empty. So


    $request = array(
            'AssetIDs'      => array('101'),
            'AttributeName' => 'name',
            'TypeCode'      => 'data_record',
           );  


fails but

    $request = array(
            'AssetIDs'      => array('101','102'),
            'AttributeName' => 'name',
            'TypeCode'      => 'data_record',
           );  


works as does

    $request = array(
            'AssetIDs'      => array('101',''),
            'AttributeName' => 'name',
            'TypeCode'      => 'data_record',
           );  

Ahh, it is because it is expecting an array (but a string is passed) and is trying to loop through the array on the asset manager call. Can confirm and posted a bug report for it here

Thanks Ben.


How many versions back are bugs being fixed now that 4.0 is out?

[quote]
Thanks Ben.



How many versions back are bugs being fixed now that 4.0 is out?

[/quote]



They are only bug fixing for 4.0 and 3.28 branches.



But I did post a fix for it on the bug report, if you want the patch for it.