A Way to exchange data with WebService RRS feed

  • Question


    Hello all,


    I want to use sync services to exchange data with a Windows mobile/SQL Server/WebService.


    So I read this article : http://www.syncguru.com/projects/SyncServicesDemoWebService.aspx  (which is the only article with WebService !!! Others are always with WCF)... but it didn't work.


    On the synchro button I have :


    // 1. Create instance of the sync components (client, agent, server)

    // In this demo the sync agent will connect to the server through WebService.

    // A web reference is added to the project and I created a thin wrapper SyncServerProviderProxy

    // That inherits from SyncServerProvider base class and redirect the calls to the web service.

    SyncAgent syncAgent = new SyncAgent();

    SyncWebServiceProxy.Service syncWebService = new SyncWebServiceProxy.Service();

    syncAgent.RemoteProvider = new ServerSyncProviderProxy(syncWebService);

    SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();

    // 2. Prepare client db connection and attach it to the sync provider

    string connString = "Data Source=c:\\bdd_test.sdf";

    if (false == File.Exists("c:\\bdd_test.sdf"))


    SqlCeEngine clientEngine = new SqlCeEngine(connString);




    SqlCeClientSyncProvider clientSyncProvider = new SqlCeClientSyncProvider(connString);

    syncAgent.LocalProvider = clientSyncProvider;

    // 4. Create SyncTables and SyncGroups

    // To sync a table, a SyncTable object needs to be created and setup with desired properties:

    // TableCreationOption tells the agent how to initialize the new table in the local database

    // SyncDirection is how changes from with respect to client {Download, Upload, Bidirectional or Snapshot}

    SyncTable tableOrders = new SyncTable("orders");

    tableOrders.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;

    tableOrders.SyncDirection = SyncDirection.Bidirectional;

    SyncTable tableOrderDetails = new SyncTable("order_details");

    tableOrderDetails.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;

    tableOrderDetails.SyncDirection = SyncDirection.Bidirectional;

    // Sync changes for both tables as one bunch, using SyncGroup object

    // This is important if the tables has PK-FK relationship, grouping will ensure that

    // and FK change won't be applied before its PK is applied

    SyncGroup orderGroup = new SyncGroup("AllChanges");

    tableOrders.SyncGroup = orderGroup;

    tableOrderDetails.SyncGroup = orderGroup;




    // 5. Kickoff sync process

    // Setup the progress form and sync progress event handler

    _progressForm = new ProgressForm();


    clientSyncProvider.SyncProgress += new EventHandler<SyncProgressEventArgs>(ShowProgress);

    clientSyncProvider.ApplyChangeFailed += new EventHandler<ApplyChangeFailedEventArgs>(ShowFailures);



    But when I execute the application, it stops on the last line (but not the least...) : syncAgent.Synchronize();


    With :


    Object of type 'Microsoft.Synchronization.Data.SyncSession' cannot be converted to type 'SyncApplication.SyncWebServiceProxy.SyncSession'.


    And I don't understand this error at all !


    Any idea please ?


    • Moved by Hengzhe Li Friday, April 22, 2011 6:34 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Tuesday, December 16, 2008 4:52 PM


All replies