none
How to pass custom variable to WCF server side web service from the Client during Sync? RRS feed

  • Question

  • I have a C# sync app that is mostly done.  I have multiple customers and I host a backend database for each.  Each customer's users will be running my client software and will need to sync to their own backend SQL database.  The web service needs to know who is calling so it can configure the connection string to that caller's database.

    How can I pass a variable during the Sync session that the server-side code can use to craft the connection string?

    PS: It would work - but I don't want to run a separate service on a separate port for each customer.  I also don't want to maintain a table of users and to which customer they belong.

    Tuesday, August 10, 2010 9:27 PM

Answers

  • i'm assuming its the offline provider then (SqlCeClientSyncProvider on the client side). You can modify the WCF service to include an extra parameter for your connection string.

    For example, you can change

    1. [OperationContract()]
    2. SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession);

    to

    1. [OperationContract()]
    2. SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession, string myServerConnString);
    • Marked as answer by P H T Wednesday, August 11, 2010 4:24 PM
    Wednesday, August 11, 2010 2:43 PM
    Moderator

All replies

  • which provider are you using?
    Wednesday, August 11, 2010 2:09 AM
    Moderator
  • I hope this answers your question ...

    the client has a web reference to the WCF web service where the provider is defined as Microsoft.Synchronization.Data.Server.DbServerSyncProvider

    (The web reference is HTTPS with basicHttpBinding and security mode="Transport")

    Wednesday, August 11, 2010 12:34 PM
  • i'm assuming its the offline provider then (SqlCeClientSyncProvider on the client side). You can modify the WCF service to include an extra parameter for your connection string.

    For example, you can change

    1. [OperationContract()]
    2. SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession);

    to

    1. [OperationContract()]
    2. SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession, string myServerConnString);
    • Marked as answer by P H T Wednesday, August 11, 2010 4:24 PM
    Wednesday, August 11, 2010 2:43 PM
    Moderator
  • Perfect - that's what i needed to know - thanks!

    I assume i will need to do this for the 3 other exposed methods too (ApplyChanges, GetSchema, GetServerInfo).

     

     

    Wednesday, August 11, 2010 4:26 PM