Re: Migrating AJAX web-services from version 3.4 to 3.5
Having just spent a frustrating day migrating some AJAX web services from 3.4 to 3.5 I thought I'd share my findings in case anyone else needs to do the same, or can re-educate me...
The fixupxml function mentioned in http://forums.nbn.org.uk/viewtopic.php?id=972 #7 now simplifies to
function fixupxml($xml)
{
$pos = strpos($xml,'<?xml'); // Find the start of the <?xml tag
$xml = substr($xml,$pos); // Discard everything before it
return $xml;
}
It now seems necessary to include the new namespace parts in the queries e.g. <dat:DatasetList> instead of <DatasetList>. These are documented at http://data.nbn.org.uk/Documentation/Web_Services/Web_Services-SOAP/
Parsing the returned XML in Javascript seems to require use of the name spaces to find elements, e.g.
var x = xmlDoc.getElementsByTagName("ns3:Species");
instead of
var x = xmlDoc.getElementsByTagName("Species");
which is what I used before. What I can't find though is any documentation on this. The website documentation, e.g. http://data.nbn.org.uk/Documentation/Web_Services/Web_Services-SOAP/Actual_Services/Species_List/ makes no mention of this - there are no namespaces in the example XML responses. Its seems necessary to print out the returned responses in order to discover what they are. They are numeric, so can't be guessed, unlike those in the requests which follow a logical naming. Am I doing something wrong as this doesn't seem right. I fear the numbers will change as soon as I've got all my code working again...!
I found that "Purpose" has changed to "DatasetPurpose" in the dataset Abstract.
I looked for documentation on changes between 3.4 and 3.5 and how to migrate, but couldn't find any on the website. Did I miss it?
I still have more code to migrate, so may find other things. If I've taken a wrong turn in any of the above can someone please let me know before I go too far in the wrong direction. Thanks.
Regards, Keith