0

I have deployed a REST service in a local SharePoint 2013 with Visual Studio 2012.

Anyway, when I try to access the svc url:

http://mylocalpc/_vti_bin/adsvc/Service.svc

I get error 404 file not found.

I have followed this tutorial

so in my solution there is an isapi folder which contains an adsvc folder. In this folder there are the following files:

Service.svc

<%@ ServiceHost Language="C#" Debug="true"
    Service="adservice.Service, $SharePoint.Project.AssemblyFullName$"
    CodeBehind="Service.svc.cs"
    Factory="Microsoft.SharePoint.Client.Services.MultipleBaseAddressWebServiceHostFactory,
    Microsoft.SharePoint.Client.ServerRuntime, Version=15.0.0.0, Culture=neutral,
    PublicKeyToken=40e75731a61cae52" %>

Service.svc.cs

using Microsoft.SharePoint.Client.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;

namespace adservice
{

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
// NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
public class Service : IService
{
    public Service() { }

    public string HelloWorld()
    {

        return "test";
    }
}

}

IService.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel;
using System.ServiceModel.Web;

namespace adservice
{
    [ServiceContract]
    public interface IService
    {
        [OperationContract]
        [WebGet(ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "HelloWorld")]
        string HelloWorld();
    }
}

What could be wrong?

EDIT: I see this in the ULS log:

Application error when access /_vti_bin/adsvc/Service.svc, Error=Could not load file or assembly 'Microsoft.SharePoint.Client.ServerRuntime, Version=15.0.0.0, Culture=neutral, PublicKeyToken=40e75731a61cae52' or one of its dependencies. The system cannot find the file specified.
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) at System.Type.GetType(String typeName, Boolean throwOnError) at System.ServiceModel.Activation.ServiceParser.GetType(String typeName) at System.ServiceModel.Activation.ServiceParser.CreateParseString(Assembly compiledAssembly) at System.Web.Compilation.BuildProvider.CreateBuildResult(CompilerResults results) at System.Web.Compilation.BuildProvider.GetBuildResult(CompilerResults results) at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetCompiledCustomString(String virtualPath) at System.ServiceModel.ServiceHostingEnvironment.HostingManager.GetCompiledCustomString(String normalizedVirtualPath) at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)

  • 1
    I used ASP.NET web service and got this done without any error. – Malin De Silva Aug 20 '14 at 14:21
  • @Malin De Silva Have tried this with SharePoint? – Gyonder Aug 20 '14 at 14:28
  • Yes created the service and connected that with a service reference. – Malin De Silva Aug 20 '14 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.