none
Sync Framework 2.1, SQL Express 2008 R2, SQL Server 2008 R2, WCF RRS feed

  • General discussion

  • I want to sync my SQL Express Clients to my SQL Server using WCF over the internet. The idea is that the WCF service will be exposed on the internet and  a service installed in each client computer will call that WCF Service. The problem is the sample http://code.msdn.microsoft.com/Database-SyncSQL-Server-e97d1208 connect to the sql express client to perform a remote provisioning. This will not work for me because the sql express clients are not exposed in the internet. Is there a sample out there that ONLY uses WCF to perform sync and doesnt require the SQL Servers to be exposed on the internet?

    Friday, April 1, 2011 8:26 AM

All replies

  • afaik, there's not much around although a lot of people has probably modified the sample themselves.

    just modify the application such that the server connection string is retrieved from a config file and modify the part where the client directly connects to the server database.

    Friday, April 1, 2011 10:12 AM
    Moderator
  • Right, you could also have an additional WCF API specially for the provisioning by passing relevant information to server.
    Friday, April 1, 2011 6:04 PM
    Answerer
  • Hi All,

     Here's my scenario: I have two clients and a server. The clients will synchroniza via wcf in a public interent. The sever cannot access the client databases directly so I need to provision on the client machine. What I intend to do create an app that I can run on the client machine that will provision the tables. Then the client have to call a WCF hosted on a server to perform the sync. Is that possible with sync framework.

    Sunday, April 3, 2011 7:27 AM
  • Right, you could also have an additional WCF API specially for the provisioning by passing relevant information to server.

     But that means the server still needs to do the provisioning which might not possible in this case since the server cannot access the client database via connection string
    Sunday, April 3, 2011 7:40 AM
  • as Jin mentioned, you can create a service operation to retrieve the scope definition from the server via WCF and apply it locally to your client.
    Sunday, April 3, 2011 8:35 AM
    Moderator
  • i have similiar problem. I used sample "WebSharingAppDemo-SqlProviderEndToEnd" and modified "RelationalWebSyncService.cs" for geting sql-connection  info and some my custom sync options  from wcf service web.config(or app.config if need use .exe) . It working good.

    Also i made one of providers is local . He don't use proxy and getting his sql-conn info and options from app.config of sync client application.
    Monday, April 4, 2011 7:01 AM
  • Thank you alll for your patience. Is the only reason the Server needs to connect to the client database directly is for provisioning? During synchronization doesn't it need to access the client database directly as well? If yes, can you help me do that as well.  If no, would this approach work:

    a. Provision the server database during design time.

    b. Copy the schema objects created via script to the other client databases.

     

    Thursday, April 7, 2011 6:20 AM
  • Actually, Server doesn't need to connect to the client database. (The sample, for simplicity purpose, happens to show everything working on same machine .)

    In real world,

    Client provider and Client proxy are running on individual client machines with connection to local db.

    Server side provider and WCF Service are running on the server machine, with connection to server db.

    Server does not connect to client database or vice versa.

    Client and Server only exchange change batches during sync.

    Yes, provisioning is a little bit special, because they must be set up correctly for client and server to sync. The idea is to provision the Server and Client in similar way. So server can provision the server db first, let client get its DbSyncScopeDescription (which is seriliazable), if the provision is simple, you can even do the provisioning separately and manually.

     

    Thursday, April 7, 2011 5:41 PM
    Answerer
  • Actually, Server doesn't need to connect to the client database. (The sample, for simplicity purpose, happens to show everything working on same machine .)

    In real world,

    Client provider and Client proxy are running on individual client machines with connection to local db.

    Server side provider and WCF Service are running on the server machine, with connection to server db.

    Server does not connect to client database or vice versa.

    Client and Server only exchange change batches during sync.

    Yes, provisioning is a little bit special, because they must be set up correctly for client and server to sync. The idea is to provision the Server and Client in similar way. So server can provision the server db first, let client get its DbSyncScopeDescription (which is seriliazable), if the provision is simple, you can even do the provisioning separately and manually.

     


    Hi Jin,

     Thank you for your patience. The server doesnt need to connect to the client to perform the sync only on provisioning? Can you guide me to a sample that shows only only that?

     

    Regards,

    Czar

    Friday, April 8, 2011 7:50 AM
  • The code samples are on this page: http://code.msdn.microsoft.com/site/search?f%5B0%5D.Type=SearchText&f%5B0%5D.Value=Microsoft%20Sync%20Framework&f%5B1%5D.Type=Affiliation&f%5B1%5D.Value=Official&f%5B1%5D.Text=Microsoft 

    By the way, from the N-tier to Sql Express or Sql Compat samples, I don't see server connect to the client to do the provisioning. May be I have some misunderstanding somewhere.  Can you point out the specific piece of code that does not work for you?

    Friday, April 8, 2011 5:39 PM
    Answerer
  • The code samples are on this page: http://code.msdn.microsoft.com/site/search?f%5B0%5D.Type=SearchText&f%5B0%5D.Value=Microsoft%20Sync%20Framework&f%5B1%5D.Type=Affiliation&f%5B1%5D.Value=Official&f%5B1%5D.Text=Microsoft 

    By the way, from the N-tier to Sql Express or Sql Compat samples, I don't see server connect to the client to do the provisioning. May be I have some misunderstanding somewhere.  Can you point out the specific piece of code that does not work for you?

    I'm usiong this code sample as reference, sinc I'musing SQL Express in the client http://code.msdn.microsoft.com/Database-SyncSQL-Server-e97d1208

    If you look at the SynchronizationHelper.cs, it ask for the connection string of the clients (or peers) and provision them based on those connection string. So it is the server that provisions the client database. I want a more passive approach.

    Saturday, April 9, 2011 4:30 AM
  • Ok, I see what you means now.

    Actually, the code that provision the client or later server is not the server code, it's the Sync Application code.

    Basically, the sync solution comprises of a few roles:

       Sync Application

       Client Provider

       Server provider Proxy (And WCF Service & Server Provider)

    The Sync Application normally runs on the client machine with client provider and server provider proxy, while the server machines runs the wcf service & server provider.

    When sync application does the provision, it only provisions the client provider as in the code

       SqlConnection conn = (SqlConnection)localProvider.Connection;

      SqlSyncScopeProvisioning sqlConfig = new SqlSyncScopeProvisioning(conn);

    The sync application does not do the provisioning for the server, which is done in another file in SqlWebSyncService.cs  SqlSyncScopeProvisioning prov = new SqlSyncScopeProvisioning((SqlConnection)this.peerProvider.Connection, scopeDescription);

      prov.Apply();

    So as long as the Sync application can send information to let server provider to provision and then provision the client in the same way as the server provision. These information from Sync App to Server can be communcated through config file or WCF API.

     

     

    Monday, April 11, 2011 5:11 PM
    Answerer
  • thaanks, JIn
    Tuesday, April 12, 2011 1:13 PM
  • Hi GreenCross,

    Have u solved your problem, i am also facing the same issue of mis understading the flow, so it would be great if you provide sample for the below    

    The clients will synchroniza via wcf in a public interent. The sever cannot access the client databases directly, manually i have taken care of provisioning  the server and client. the client just have to call a WCF hosted on a server to perform the sync.

     

     

     

    Thursday, May 12, 2011 10:41 AM
  • This is the exact same requirements as a project I'm nearly coming to the end of - Sync FX 2.1, SQL 2008 Server, SQL 2008 Express using WCF.

    I have the sync working on our local network and am in the process of converting it to WCF.  I have the client provisioning done, nearly finished the sync.

    I've learnt a lot and it ended up a lot simpler than I thought it would be.

    Thursday, May 12, 2011 7:21 PM