Last active
August 29, 2015 14:01
-
-
Save mdnmdn/5bc58ad79525b959affd to your computer and use it in GitHub Desktop.
WCF REST on Sharepoint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<PropertyGroup> | |
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |
<!-- .... --> | |
<!-- | |
Add .svc to let build tool to substitute$SharePoint.Project.AssemblyFullName$ like | |
placeholders during build process. | |
use ; to separate multiple: svc;ashx;... | |
--> | |
<TokenReplacementFileExtensions>svc</TokenReplacementFileExtensions> | |
</PropertyGroup> | |
<!-- .... --> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ServiceHost | |
language= "C#" | |
Service="MyNamespace.TestService, $SharePoint.Project.AssemblyFullName$" | |
Factory= "Microsoft.SharePoint.Client.Services.MultipleBaseAddressWebServiceHostFactory, | |
Microsoft.SharePoint.Client.ServerRuntime, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%> | |
<!-- | |
Microsoft.SharePoint.Client.Services.MultipleBaseAddressWebServiceHostFactory for REST | |
Microsoft.SharePoint.Client.Services.MultipleBaseAddressBasicHttpBindingServiceHostFactory for SOAP | |
http://host/sitecollurl/_layouts/15/solution_name/SampleService.svc/Do | |
http://host/sitecollurl/_layouts/15/solution_name/SampleService.svc/DoWork/12 | |
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace MyNamespace | |
{ | |
[ServiceContract] | |
public interface ITestService | |
{ | |
[OperationContract] | |
[WebInvoke(Method = "GET",ResponseFormat = WebMessageFormat.Json,BodyStyle = WebMessageBodyStyle.Bare)] | |
string Do(); | |
[OperationContract] | |
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json,UriTemplate = "DoWork/{id}")] | |
// .../_layouts/15/solution_name/SampleService.svc/DoWork/12 | |
string DoWorkWithParams(int id); | |
} | |
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] | |
public class TestService : ITestService | |
{ | |
public string Do() | |
{ | |
return "OK"; | |
} | |
public string DoWorkWithParams(int id) | |
{ | |
return "Do: " + id; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment