Consume your custom (SharePoint 2013 hosted) WCF Data Service in a SharePoint 2013 App
I think this will be my shortest post ever. To consume your custom (SharePoint 2013 hosted) WCF Data Service in a SharePoint 2013 App you can simply follow the instructions you find here: http://msdn.microsoft.com/en-us/library/jj163088.aspx.
Then why is this still worth a post? Simply because I think that it’s very easy to oversee this option and start digging in the wrong direction. In my case I believed that because a SharePoint hosted WCF Data Service is basically available at
hostweburl + '/_vti_bin/your_data_service_folder/your_data_service.svc'
It would be also accessible. But I found that available isn’t the equivalent of accessible. I’m still not sure whether I’m facing a flaw in my SharePoint 2013 environment or whether it really is not possible to go beyond the boundaries of the host web using SP.RequestExecutor or AppContextSite (also see my question here: http://social.msdn.microsoft.com/Forums/en-US/appsforsharepoint/thread/92242740-76bc-4f43-97e7-9cba348d2770/#f58df6e4-f73d-400c-8750-0dc05a3f6f7b). But using External ContentTypes for Apps I found a quick and easy way to consume my custom (SharePoint 2013 hosted) WCF Data Service afterall.
To make things work for a WCF Data Service you may need to change the following line in the sample code
"accept": "application/json; odata=verbose",