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.yiiframew...ate-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.
Page 1 of 1
Restful Webservice
#2
Posted 03 October 2012 - 09:10 AM
What do you need xml for ?
Just curious.
It's not very suited for the web, IMO.
Just curious.
It's not very suited for the web, IMO.
"Less noise - more signal"
#3
Posted 03 October 2012 - 09:17 AM
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.
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.
Rodrigo Coelho
Check my extension
giix: a code generator for Yii.
The complete beginner's study guide for the Yii Framework
Check my extension
giix: a code generator for Yii.

The complete beginner's study guide for the Yii Framework
#5
Posted 03 October 2012 - 11:31 AM
actually I need to convert active record objects to xml, im not sure if simpleXml does that, any hints?
#6
Posted 03 October 2012 - 12:00 PM
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.
If your models follow a predictable structure, you can write a class to do the conversion.
Rodrigo Coelho
Check my extension
giix: a code generator for Yii.
The complete beginner's study guide for the Yii Framework
Check my extension
giix: a code generator for Yii.

The complete beginner's study guide for the Yii Framework
#7
Posted 04 October 2012 - 03:38 PM
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
So here it is:
https://github.com/s.../class.json.php
"Less noise - more signal"
Share this topic:
Page 1 of 1

Help














