anilsojitra
Posts: 0
Joined: Fri Jan 20, 2012 10:51 am

REST services and JSONP

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?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

REST services and JSONP

JSON or XML is fine.

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

anilsojitra
Posts: 0
Joined: Fri Jan 20, 2012 10:51 am

REST services and JSONP

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.

Eric5020946
Posts: 0
Joined: Tue Sep 18, 2012 4:31 pm

REST services and JSONP

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

anilsojitra
Posts: 0
Joined: Fri Jan 20, 2012 10:51 am

REST services and JSONP

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

Thanks.

Eric5020946
Posts: 0
Joined: Tue Sep 18, 2012 4:31 pm

REST services and JSONP

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

Return to “Issues”