Problem returning database from webservice method

mordymordy Posts: 10
edited April 5, 2005 12:58PM in SQL Compare Previous Versions
Hi there, as part of our evaluation I'm trying to return the master database for a SQLCompare application from a web service function but I've run into a problem, the compiler is returning the following error :

"Additional information: Server was unable to process request. --> Method wsRegisterMaster.RegisterMasterDB can not be reflected. --> There was an error reflecting 'RegisterMasterDBResult'. --> There was an error reflecting type 'RedGate.SQLCompare.Engine.Database'. --> You must implement the Add(System.Object) method on RedGate.SQLCompare.Engine.ExtendedProperties because it inherits from IEnumerable."

This part of the error report "'RedGate.SQLCompare.Engine.Database'. --> You must implement the Add(System.Object) method on RedGate.SQLCompare.Engine.ExtendedProperties because it inherits from IEnumerable" seems to be common to all attempts to use the component within a webservice class.

I've tried a few different ways of using the database.register method within a web service but this error is always displayed, do you have an example of how to return the 'template' database from a webservice? Our master database will be behind a firewall and the easiest and most secure way to get at it from a client application will be via a webservice running on the remote server that has access to the SQL Server running behind the firewall. I'm by no means an expert in webservices so there could be a simple solution to this that I'm missing but I'd appreciate any help you could give me :)

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hi Mordy,

    Thanks for your post to the forum.

    Do you have any idea why the code is being reflected? Is this something that you've written in your own code, or something that the .net Framework is doing?

    As a side note, the Database object cannot be consumed by a webservice client because it's not serializable. To send a Database object over a network, you'd need to figure out some way of serializing it or use the SaveToDisk method to produce a snapshot file and send the bytes of the file across the network.

    Hopefully this information is helpful. Please get back to me if you still have problems.
  • Hi Brian, my initial plan was to host a webservice that had access to the database I would use as the template and from a local application on a client machine to have an application to synchronise the structure of a database with this master-template in order that we could easily reflect changes to MSDE databases running on client machines - our master database will be behind a firewall so I only really have port 80 to work with which is why the webservice is probably going to be my best option for peeking through it to register the master database to use as my template for the comparison.

    Plan A was a simple function in the webservice to register the database and return the created database object to the local client application which would then use it as the template to check against its' own local copy and synchronise any changes thereby radically simplifying deployment of new versions to the client by ensuring their local MSDE databases were always in synch with our release versions - it's become very easy to deploy new software revisions with .NET but there's always that nagging fear that we've added a column to a table and broken integrity with the local databases come release day and my evaluation project is to establish whether we can incorporate SQLCompare into a tool to take away this worry :)

    The reflection seems to be something the framework is doing - that's a little above where I'm at on the .NET learning curve at the moment, in a nutshell what I need the webservice to return to the client application is a registered database object containing the structure of the 'template' database on our DB server.
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hi Mordy,

    I see. Then I'd recommend programming the webservice to register and save a snapshot of the database, then return it to the web service consumer as an array of Bytes. At the consumer end, you can save the bytes to a temporary file and read them back into a database object with Database.LoadFromDisk.
  • Thanks Brian, I'll give that approach a try.

    Edit: The evaluation popup is causing the webservice to fail as it cannot display UI elements :( Thanks for your help in trying to get this prototype working but I think I'll have to rethink my strategy on this project.

    Regards,

    Mike
  • Just wanted to thank Brian and Daniel for their help in working up a solution, we test ran our prototype last night and it worked like a charm :)
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    No problem... <hannibal>I love it when a plan comes together!</hannibal>
This discussion has been closed.