Saturday, November 24, 2012

Telerik OpenAccess Service works locally but not hosted

I have 3 projects, one with the entity model, another one with the OData v3 service generated from the entity model, the third one is an asp.net web application.

During local development the service reference I added into the web app is from same solution: http://localhost:55001/MyModelService.svc

After everything was successfully tested I then published the service project and hosted it on a third party hosting service. I was able to browse the service successfully by going: http://service.myapp.com/MyService.svc

I then re-added the existing service reference into my web app with the remote url shown above, published the web app on another hosting service.

When I load up the web app I got an error:
DataServiceQueryException was unhandled by user code
An error occurred while processing this request.

The issue turned out to be really fundamental which I missed out through all my WCF learnings: the cross domain policy xml!

The solution is to add a clientaccesspolicy.xml into the OpenAccess Service WCF app root folder with the following content: