Creating
a Custom WCF Service in SharePoint Server:-
Add This Code to IRevert.cs file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace WcfService
{
[ServiceContract]
public interface IRevert
{
[OperationContract]
void Revert(string listName, int listItemId);
}
}
Add This Code to Revert.cs file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace WcfService
{
using Microsoft.SharePoint.Client.Services;
using System.ServiceModel.Activation;
using Microsoft.SharePoint;
[BasicHttpBindingServiceMetadataExchangeEndpointAttribute]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class RevertService : IRevert
{
public void Revert(string listName, int listItemId)
{
SPList oList = SPContext.Current.Web.Lists[listName];
SPListItem oItem = oList.GetItemById(listItemId);
if (oItem.Versions.Count > 1)
{
oItem.Versions.Restore(1);
}
}
}
}
<%@ServiceHost Language="C#" Debug="true"
Service="WcfService.RevertService,
$SharePoint.Project.AssemblyFullName$"
Factory="Microsoft.SharePoint.Client.Services.MultipleBaseAddressBasicHttpBindingServiceHostFactory,
Microsoft.SharePoint.Client.ServerRuntime, Version=14.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c" %>
Add to this .csproj file:-
<TokenReplacementFileExtensions>svc</TokenReplacementFileExtensions>
Run below Command:
svcutil.exe
http://<server-name>/_vti_bin/CustomWCF/Revert/Revert.svc/mex?wsdl
After run we can see generated two file in this path "C:\wcftest"
1. output.config file
2. RevertService.cs file
Source: http://msdn.microsoft.com/en-us/library/ff521581(v=office.14).aspx
Thank You.

















CC71098BD3
ReplyDeletepara kazandıran oyunlar
para kazanma
temu güvenilir mi
ReplyDeleteWhen exploring various printing techniques, many are discovering the advantages of Direct to Film Transfers for vibrant and durable designs. This method offers high-quality results with less setup time, making it a popular choice for small businesses and hobbyists alike. By utilizing Direct to Film Transfers, creators can achieve detailed and long-lasting prints on a variety of fabrics.