Restful Webservice

Hi guys.

I want to build a webservice that returns xml.

As far as I know with soap you create a bunch of methods that do a lot of stuff, ignoring the type of request.

Is it possible to create a restful api that returns xml?

in this link : http://www.yiiframework.com/wiki/175/how-to-create-a-rest-api/

he created an api using rest and returning json. And the method CJSON::encode to turns objects into json .

is there a method that takes an object and generates xml?

sorry im kind of lost.

What do you need xml for ?

Just curious.

It’s not very suited for the web, IMO.

You are on the right track following that wiki for the REST part.

To generate the XML, you create your own views. Or maybe SimpleXML can help you.

Don’t forget to set the proper XML response content-type using header.

hum, this webservice will provide xml for an iphone app.

actually I need to convert active record objects to xml, im not sure if simpleXml does that, any hints?

It won’t convert automatically, you’ll have to manage the process by using its methods (like addChild).

If your models follow a predictable structure, you can write a class to do the conversion.

I figured that this is such a common task, and it is, converting JSON to XML.

So here it is:

https://github.com/s.../class.json.php

Thanks, thats what I need…