Apps can only call the OOB CSOM and REST endpoints
By Anatoly Mironov
As a SharePoint architect or a SharePoint developer, you must have been thinking about the benefits/limitations of SharePoint apps a lot. I want to point out one of them today, which is very important: using custom webservices deployed to SharePoint inside apps. That is impossible and it is designed to be so due to the security architecture in the sharepoint app framework. I have read much about SharePoint apps (books, whitepapers, blog posts) and stumbled over these two contradictive statements:
[…] app authenticatton is supported only for scenarios in which an app is calling to the SharePoint host environment by using client-side object model (CSOM) or the REST API. SharePoint 2013 does not support app authentication in any other endpoints beyond these. This means it is not possible to develop and deploy a set of custom web service entry points that support app authentication.
Microsoft SharePoint 2013 App Development, Microsoft Press, page 88.
This is really important to know, because it is exactly the opposite to what it is said in a Microsoft WhitePaper, where we are requested to “some outside-of-the-box thinking”:
The main reason why you would still use full-trust solutions is that a feature or API you want to use is not yet available through the REST endpoints or CSOM APIs. However, this doesn’t mean you can’t still use the server object model from an app that is on-premises. It just requires some outside-of-the-box thinking. Instead of writing a full-trust solution that completely covers the entire business scenario you are trying to satisfy, write a full-trust solution that exposes the functionality you are looking for as a REST endpoint and write an app that can use that endpoint. This will allow your solution to scale while reducing the overall exposure of full-trust code to the SharePoint environment.
Deciding between apps for SharePoint and SharePoint solutions, Microsoft. Keenan Newton.
Just to clearify, the first statement is correct. The second is unfortunately not correct. To be sure I created a web service which I deployed as a farm solution. And when I tried to invoke this webservice from my app I got 403 error and this message
The endpoint /testapp1/\_vti\_bin/mywebservice.svc
is not accessible in the context of a SharePoint App.
The endpoint cannot be added within the manifest neither:
Summary
While developing SharePoint apps we are restricted to the OOB CSOM and REST endpoint only. OOB here means out-of-the-box, not outside-of-the-box.
Comments from Wordpress.com
Priyanka - Jul 3, 2016
I just need to deploy infopath in AppWeb i am getting the error “The endpoint /sites/tssrnd/infopathappweb/_layouts/15/formserver.aspx is not accessible in the context of a SharePoint App”.Can i use infopath in AppWeb or not ?