I have a sharepoint site with some OOB lists (documents and tasks). I want to catch list changes in my program.
I tried to create WCF service and Remote Event Reciver (RER) via CSOM for this service, but no messages were catched by the WCF service.
The WCF service and RER are created in simple C# application (console application).
Class for WCF service
public class RemoteEventService : Microsoft.SharePoint.Client.EventReceivers.IRemoteEventService
{
public void ProcessOneWayEvent(SPRemoteEventProperties properties)
{
// some code here
}
public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
{
SPRemoteEventResult result = null;
ClientContext context = null;
// some code here
return result;
}
}
WCF-service creation
using (ServiceHost host = new ServiceHost(typeof(RemoteEventService)))
{
host.Open();
host.Description.Behaviors.Find<ServiceAuthorizationBehavior>().ImpersonateCallerForAllOperations = true;
Console.WriteLine("Started service at " + host.BaseAddresses[0].ToString());
Console.WriteLine("Press <enter> to terminate the Application");
Console.ReadKey(true);
}
Remote Event receiver creation
// check that RER doesn't exist
EventReceiverDefinitionCreationInformation receiverAdded =
new EventReceiverDefinitionCreationInformation();
receiverAdded.EventType = EventReceiverType.ItemAdded;
receiverAdded.ReceiverUrl = SERVICE_URL;
receiverAdded.ReceiverName = "TestDocReceiverAdded";
receiverAdded.Synchronization = EventReceiverSynchronization.Asynchronous;
docList.EventReceivers.Add(receiverAdded);
context.ExecuteQuery();
The RER was created (it is available in debug check on next run of my application) but WCF-service didn't catch any messages.
I have checked that WCF-serivce is available from network where Shapoint Site is hosted. Im not sure if the user (that is used to connect to sharepoint in my app) have enough permissions to manage sharepoint OOB lists.
Is it posiable to add RER to sharepoint OOB list from NOT sharepoint-app? If no what is the best way to catch list changes in my program?