How to develop web service to update items of CSLA List.

How to develop web service to update items of CSLA List.

Old forum URL: forums.lhotka.net/forums/t/7962.aspx


tarekahf posted on Sunday, November 08, 2009

I have developed parts of the application which require using a web service. I am planning to CSLA.NET 2.0 Approach to implement this application and use web services to be consumed/invoked from Lotus Notes Application (version 7.x).

I did the following:

1. Implemented the list items as Editable Child. To give you an idea, the child object represents a "Docment in the Archive" which a has a URL Link to a PDF File. The data is stored in SQL Server, and the Document object that need to be interfaced to Lotus Notes has the following properties:

- eArchDocID
- DocDateGreg (yyyy-mm-dd)
- OrgCode
- RefNo
- ExterRefNo
- Subject
- DocDirection (Incoming/Outgoing)
- Destination (Inside Company, Outside Company)
- FromToExternalOtherTxt (used if Outside)
- FromToInternalOrgCode (used if for Inside)
- FromToInternalDescShort (Short Description of the Organization)
- FromToInternalDescFull (Full Description of the Organization Code)
- FileURL (full path to file in URL Format)
- IsFollowup (Flag 0 or 1)
- IsLinked (Flag 0 or 1)

2. Implemented the parent as a Read Only List of the Editable Child Document Objects.

3. My plan is to have the web service to be consumed from Lotus Notes using XMLHttpRequest Object. I have tested this method, and it works very well.

Now here is my problem...!

How I have to implement the web service ? Should I create another wrapper class based on a Strongly Typed List as per the recommendation for the Book of CSLA ? Then I have to generate this list again by copying the elements from the CSLA List to this new list ?

For each child element in the list, the flag "IsLinked" will be changed in Lotus Notes to be either "0" or "1" for certain elements. Then I need to call another web service to update back the values of "IsLinked" of every child in the list which was changed in Lotus Notes, to SQL Server.

How I can implement this web service to carry out the update process. Remember that I already implemented the Update Logic in the CSLA List Root Object.

Appreciate your help.

Tarek.

tarekahf replied on Sunday, November 08, 2009

I was thinking this problem over, it appears to me that it is not possible (or no added value) to develop a CSLA List of Editable Child objects, then in a web service, copy this list and its items to another List Object of simple Objects which represents the CSLA Editable Child, then eventually, pass the result to the client part which will consume the web service. I think it is enough to have CSLA List of Read Only Child Objects.

Because, when the client will change the "IsLinked" property of selected items in the list, then I could not figure out how to pass back the updated list from the client application (Lotus Notes) to the web service. When the Update web service is invoked in this case, we will have a List Object in the Web Service, then how we can perform the update through the CSLA List Object...??!!

Because at this point in time, if the CSLA List is not cached is a Session Variable, then how we can reconstruct it, and perform the update on each item ? Should we rebuild the CSLA List ? I do not think that caching the CSLA List is a safe option in this case.

How about performing the update using a command object. Probably we can desing the CSLA Command Object, so that it will be created inside the web service, then generate series "Update" sql statements inside the object by looping over the items in the List Object, and finally execute the command object.

I am really confused and not exactly sure what is the best way to implement this logic.

Appreciate your help.

Tarek.

Copyright (c) Marimer LLC