Saturday, December 6, 2008

Well formed XML for RESTful web services ...

I'll probably get no response or flames telling me to "just set debug
to 1", but ....

I've set up my VolunteerCake code to be a RESTful web service by using
the Router::parseExtensions() and Router::mapResources() magic. This
works fine as long as debug is not greater than 1.

When debug is greater than 1 however, the XML that gets returned is
broken due to problems with the way the SQL debug is spit out.


I traced this down to a call In the close() function of
dbo_source.php, to showLog() which spits out the SQL in an HTML table

I call the web service and get the XML as expected. The closing XML is
followed by the dump of the SQL like:

</VolunteerCake><!-- 0.9699s --><table class="cake-sql-log"
id="cakeSqlLog_1228604311493b0397a19568_61229664" summary="Cake SQL
Log" cellspacing="0" border = "0">
<caption>(default) 36 queries took 127 ms</caption>

Other web service tools I've worked with operate by giving you access
to the debug data so you can spit it out as part of the XML if you
want to, so you end up with something like:

<VolunteerCake><myData>non-debug data</myData><debug>debug data
(usually wrapped in a CDATA)</debug></myData></VolunteerCake>

Ideally Cake shouldn't be changing the content-type and spitting out
HTML after the well-formed document has been created anyway.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: