Sunday, September 28, 2008

Coldfusion RETS Getting the MetaData

Once logged into the server we need to get the metadata to decipher the schema and know what fields are available to us. It is really important to read through section 11 and 12 of the RETS 1.5 Specification . It is a painfull read for sure, and it is by no means a developers guide, but the metadata is what RETS is all about. The metadata is arranged in a hierarchy, with the idea being you can grab the top level documents, which will have the IDs to the next level, etc. Trust me when I tell you that you will wind up poking around seeing what you can pull up, and what seems to make sense. The top nodes of the metadata are SYSTEM and RESOURCE. In MRED the SYSTEM node is all but useless...

Yeah, thanks for that, RESOURCE is more interesting...

Now we are getting somewhere. Anyone familier with MLS data will recognize these as the top level of MLS databases. I ommited the last two for space, OpenHouse and Tour, but you get the idea. The Property resource is what it is all about, and we can tell there are 18 classes under it, and the key field is LN (ListingNumber). Before we proceed, lets run down the code used to pull the metadata.

Again, nothing fancy for the demostration purposes. We are ACCEPTing anthing the server chooses to send us back. We are passing the first row from the application.RetsCookie struct that we set earilier. The last three arguments is where it all happens, and where reading the spec will come in handy. TYPE and ID are how you navigate the nodes, FORMAT determines what the returned XML will look like. There are three FORMAT values, COMPACT, COMPACT-DECODED and XML-STANDARD. For pulling metadata, the FORMATS don't really matter much (at least as far as I can tell, I am still learning). Try pulling the same node in each and you will see what I mean. The FORMAT will be critical when pulling actual data later, so we will come back to that. I am going to cut to the chase and tell you what TYPEs and IDs I pulled to get what I needed. Use format COMPACT for now.


Browse the XML files and you should start to get a pretty good handle on where things are headed. Next up, let's do something with this METADATA...


MichaelE said...

Hi James -
Thanks... I've looked at several CF Rets options and never got it working... till now, and with a project in the works that requires a RETS data connection, your timing is exquisite.

With this code, I am already caught up to you and waiting for the next gems of wisdom.


alpenrover said...

Is the code available? I just see advertisements where I suspect the code was.


txmlsgirl said...

Hi! I'm also wondering if code is available for this part. I would love to see the code. Thank you!