Page 1 of 1

REST services and JSONP

Posted: Tue Nov 13, 2012 1:54 pm
by anilsojitra

I am intending on using tiggzi to build a mobile web app that consumes data from a REST service. My client currently has a desktop website with a CMS. I have requested that in order to consume information from the CMS, it needs to be exposed first via a REST web service. For tiggzi to consume this REST web service do I also need to request that the data is returned using JSONP or will pure JSON/XML data be okay?


REST services and JSONP

Posted: Tue Nov 13, 2012 5:45 pm
by maxkatz

JSON or XML is fine.

JSONP is a workaround for cross-domain service invocation, however, the response is still sent in JSON format.


REST services and JSONP

Posted: Tue Nov 13, 2012 7:43 pm
by anilsojitra

Thanks for your quick response Max.

Just for my understanding, if the mobile web app is on domain A and the web service is implemented on domain B, does the web service only need to implement JSON results even though it's going to be invoked from domain A.

The web service is only going to be GET so that CMS updates to the desktop website can be reflected in the mobile web app.

Is that correct?

Thanks for your help.


REST services and JSONP

Posted: Tue Nov 13, 2012 8:29 pm
by Eric5020946

you need JSONP or allow cross domain requests since you have 2 different domains here


REST services and JSONP

Posted: Tue Nov 13, 2012 9:53 pm
by anilsojitra

You say "or" - can you recommend how to allow cross domain requests if the web service is returning JSON?

Thanks.


REST services and JSONP

Posted: Tue Nov 13, 2012 9:58 pm
by Eric5020946

try this in your php file
header("access-control-allow-origin: *");
header('Content-type: application/json; charset=utf-8');

another option is mod_proxy for apache if your admin won't be able to change httpd.conf and relevant settings