Q: I've read your articles in Visual Studio Magazine.
I was wondering if you knew how to keep “state” in a web service relative to properties.
Meaning if I do something like this :
Dim objCustomersWS as new
webservice.class
objCustomersWS.Name
objCustomersWS.Address
which are properties set in the web service, is it possible to get these values on the client side? I have tried and can not achieve this.
A: Keeping state in the web service class, on the server, is a bad idea. It leads to a very chatty API between the server and the client.
Looking at your very trivial example above, you’ve already made two round trips to the server. Expand that design to an application of any reasonable size, and your application will have dreadful performance. It’s far better to view the web service as an object server: you request an object from the server, modify it on the client, and then send the results back to the server:
Dim objCustomersWS
as new
webservice.class
Dim customerObj
as
webservice.Document
customerObj =
objCustomersWS.RetrieveCustomer
objCustomersObj.Name =
newName
objCustomersObj.Address =
newAddr
objCustomersWS.SubmitCustomerChange( customerObj
)
You retrieve a customer (or set of customers) from the server, make all the modifications locally, then send it back to the server.
I hope that helps.
Visual Studio Magazine
Much writing here.
