Hi,
I am trying to access custom WCF web service from SP-Hosted Add-in and getting below error, however if we use same peace of code in normal web application I am able to get the data from custom web-service.
Error: Response Status Text: “Error:Access is Denied.\r\n
Could you please share the solution, if someone has come across this situation and got the solution?
I had written below code to call web service and it is written in App.js
requestUri= "webservice url /parameter ";
return $.ajax({
url: requestUri,
type: "GET",
data: "",
headers: { "accept": "application/json;odata=verbose" },
ContentType: "application/json; charset=utf-8", dataType: "json",
success: function (data) { alert(data); }, error: function (data) { alert(data); } });
Web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Namespace.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<identity impersonate="false" />
<authentication mode="Windows" />
</system.web>
<system.serviceModel>
<client />
<!--<bindings>
<basicHttpBinding>
<binding name="ExampleBinding" transferMode="Streamed" />
</basicHttpBinding>
</bindings>-->
<services>
<service name="ServiceName" behaviorConfiguration="ServiceBehavior">
<endpoint address="" binding="webHttpBinding" contract="serviceController" behaviorConfiguration="httpBehavior">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="httpBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<standardEndpoints>
<webScriptEndpoint>
<standardEndpoint name="" crossDomainScriptAccessEnabled="true" />
</webScriptEndpoint>
</standardEndpoints>
</system.serviceModel>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*"/>
<add name="Access-Control-Allow-Headers" value="Content-Type, Accept" />
<add name="Access-Control-Allow-Methods" value="POST,GET,OPTIONS" />
<add name="Access-Control-Max-Age" value="1728000" />
</customHeaders>
</httpProtocol>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>