Click to See Complete Forum and Search --> : Best practice? (SQLCommand and Web Services)
Geert Verhoeven
10-09-2006, 08:56 AM
Hi all,
I have a database that is in a DMZ. To be able to access the DB easily I was planning to create a web service that does all the DB access so that it can be used via a WinForm app over the internet.
My intention was to pass a SQLCommand to the WebService but apparently this is not Serializable so it doesn't work. I wanted to pass the SQLCommand to avoid having to put all the business knowledge in the webservice and to make it as dynamic as possible.
What is the best practice for such a problem?
All help is welcome !
Greetz,
Gette
sirpelidor
10-09-2006, 01:17 PM
My intention was to pass a SQLCommand to the WebService but apparently this is not Serializable so it doesn't work.
I wanted to pass the SQLCommand to avoid having to put all the business knowledge in the webservice and to make it as dynamic as possible.
Hi, I came across this article (http://www.thescripts.com/forum/thread538408.html) . The guy made a wrapper class for the sqlcommand object, and he serialize an instance of his wrapper class.
As for deserialization, he basically recreating the SqlCommand based on the information from his wrapper class.
See if this helps...
p.s: i have not tried this technique yet but I can see I'll have to use something simliar on my up coming project. Would you mind post a note if you get it working? Thanks.
Cstick
10-09-2006, 10:58 PM
This is not an answer to your how question, but an idea for your what question.
In my opinion, I feel like your implementation idea is not the best practice.
What I'd suggest is that you have basically 4 projects:
-UI, obvious.
-BLL, all of your objects and processes, referenced by UI and contains I/O methods for the below web services.
-Web Services, wraps the below DAL methods.
-DAL, actually queries your database server, referenced by web services.
The benefit to this pattern is that if you change your DAL, then you do not necessarily have to update your BLL and UI. Your implementation means that you'd have to update your BLL and UI, hence your clients, with every data access change. Also, the suggested pattern would allow you to reuse the DAL for multiple user interfaces such as a standard windows client and also a smart client such as a PDA.
See the below article. Take a look at his architecture for accessing data via web services, it follows what I would be considered a more standard pattern.
http://www.codeproject.com/smartclient/smartclientsoa.asp
Also, if you think about the idea behind web services, they are supposed to encapsulate functionality. In your case you are trying to remove the functionality from it.
Hope that helps.