private System.ServiceModel.EndpointAddress CreateServiceEndpoint(string svcName) { return new System.ServiceModel.EndpointAddress(string.Format("{0}/{1}", _baseUrl.Trim('/'), svcName)); } private CustomBinding CreateServiceBinding() { CustomBinding customBinding = new CustomBinding(); customBinding.Elements.Add(new BinaryMessageEncodingBindingElement()); if (System.Windows.Browser.HtmlPage.Document.DocumentUri.Scheme.StartsWith("https")) { customBinding.Elements.Add(new HttpsTransportBindingElement() { MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue }); } else { customBinding.Elements.Add(new HttpTransportBindingElement() { MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue }); } return customBinding; }
In SharePoint 2010, our features deployed WCF files to TEMPLATE\FEATURES\OURFEATURE\WCF. We would create through code a virtual directory in IIS to access our WCF web services. I'm converting our 2010 feature to 2013, and in doing so I have moved our WCF .svc files to ISAPI so that we don't have to create virtual directories in IIS. I'm finding that whenever my site tries to call one of our services, Fiddler shows that there is a redirect to _layouts/15/AccessDenied.aspx. I have tried the old method of creating an IIS vritual folder, and I still get redirected to AccessDenied.aspx, so I'm thinking that I need to change something in the .svc itself. We call our WCF services from Silverlight, and we build bindings and endpoints on the fly in Silverlight code (shown above).
Service files are not using a factory. I've tried using a factory, and I just get Endpoint not found.
<%
@ServiceHostLanguage="C#"Debug="true"Service="Project.WCF.WCFServices.Mapping"CodeBehind="Mapping.svc.cs"%>
namespace Project.WCF.WCFServices { [ServiceContract(Namespace = "Project.WCF.WCFServices")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)] [Serializable] public class Mapping { [OperationContract] public AddressValidation OrderData() { AddressValidation data = new AddressValidation(); try { dbSite = GetSiteConfiguration(); data = FormatData(); return data; } catch (Exception e) { data.Error = e.Message + "\n\n" + e.StackTrace; return data; } } }
All this worked in SharePoint 2010, but in 2013, I get redirected to AccessDenied.aspx every time. What can I do to get this working again?