locked
Way to exchange data 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);

    clientEngine.CreateDatabase();

    clientEngine.Dispose();

    }

    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;

    syncAgent.Configuration.SyncTables.Add(tableOrders);

    syncAgent.Configuration.SyncTables.Add(tableOrderDetails);

     

    // 5. Kickoff sync process

    // Setup the progress form and sync progress event handler

    _progressForm = new ProgressForm();

    _progressForm.Show();

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

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

    syncAgent.Synchronize();

     

    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:35 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Monday, December 15, 2008 5:01 PM

Answers

  •  

    good to see so many folks pitching in help each other.

     

    i would say construct the webservice is easier than to construct the WCF service for Mobile. regardless using web service or wcf as the mid tier, some generic tips apply: http://forums.microsoft.com/sync/ShowPost.aspx?PostID=3609978&SiteID=75

     

    in your case, on the client side, you need to remove the duplicated classes in the references.cs file to solve this problem.

     

    thanks

    Yunwen

    Saturday, January 10, 2009 4:34 AM
    Moderator

All replies

  • Anyone can help ?

    Tuesday, December 16, 2008 4:33 PM
  • Hi,

     

    It's a while since I did anything with that particular project, I'll take a look at the code tomorrow and see if I can help out.

     

    Mike

     

    Tuesday, December 16, 2008 10:45 PM
  • Why don't you take a look at this video ?
    http://msdn.microsoft.com/it-it/sync/cc137124(en-us).aspx
    You should find something very helpful
    Claudio
    Wednesday, December 17, 2008 9:38 AM
  • Unfortunately, Not because they use WCF...to exchange data... They didn't explain it with Web Services.
    Wednesday, December 17, 2008 10:04 AM
  • WPF ? I think you mean WCF :-)
    Why do you need a Web Services?
    Wednesday, December 17, 2008 10:15 AM
  • Yes WCF ! (I correct it in my post Wink )

    Because, I'm with VS2005 so it's easier for me Web Services and I want to use Sync on Windows Mobile and I see WCF is not really compatible with the Compact Framework so Web Services is easier (...!).
    Wednesday, December 17, 2008 10:34 AM
  • ok, now it's clear.
    Sorry but I'm not a "compact dev"
    After reading here
    http://209.85.129.132/search?q=cache:ZCfBNOO7qCMJ:https://forums.microsoft.com/msdn/ShowPost.aspx%3FPostID%3D1148702%26SiteID%3D1%26pageid%3D0+%22.net+compact+framework%22+consume+WCF+web+service&hl=it&ct=clnk&cd=9&gl=it
    I've learned that you can't Access WCF
    basicHttpBinding from Compact Framework
    Why don't you upgrade you app to .NET Compact Framework 3.5 ?
    Windows Communication Foundation (WCF) is supported by the .NET Compact Framework 3.5.
    http://blogs.msdn.com/andrewarnottms/archive/2007/08/21/the-wcf-subset-supported-by-netcf.aspx
    Wednesday, December 17, 2008 10:56 AM
  • From the second link :

    "Many people have been asking about what subset of .NET 3.0's Windows Communication Foundation (WCF) will be supported by the .NET Compact Framework 3.5."

    Maybe it's not the case I don't know ! But Web Services should work with Sync if someone know how... ! (and I don't think VS2005 and WCF is so easier Stick out tongue with VS2008 Yes I'm Okay).


    Wednesday, December 17, 2008 11:25 AM
  • Any idea plrease ?
    Saturday, December 27, 2008 5:47 PM
  • Hello,

    without diving into your code - have you had a look at the Mobile LOB example?

    They use a backend webservice and a local proxy class and it works fine. Perhaps you have a look and find some misconfiguration in your app.

     

    Regards,

    Andreas

    Wednesday, January 7, 2009 9:44 AM
  •  

    good to see so many folks pitching in help each other.

     

    i would say construct the webservice is easier than to construct the WCF service for Mobile. regardless using web service or wcf as the mid tier, some generic tips apply: http://forums.microsoft.com/sync/ShowPost.aspx?PostID=3609978&SiteID=75

     

    in your case, on the client side, you need to remove the duplicated classes in the references.cs file to solve this problem.

     

    thanks

    Yunwen

    Saturday, January 10, 2009 4:34 AM
    Moderator