In my view, there are three options for WCF with CSLA:
Option 1 is simplest, but may transfer unnecessary data over the wire (on a save) because the data portal makes sure you have the same context (object graph, security, etc) on client and server.
Option 2 is somewhat hard, but is next simplest. You lose most of the value of the data portal, but if you use something like ANDS on the server it is probably not too hard. Just remember your client and server are still part of the same app (because this is n-tier), and you are just implementing your own plumbing between the two instead of allowing the data portal to do the work for you.
Option 3 is hardest, because you are creating two applications - client and server - that just happen to communicate with each other using well-defined, contractual messages. The service and message definitions can't be changed arbitrarily, because that breaks other clients - so you need to architect the server in anticipation of maintaining multiple versions of your service/message contracts over time.
Option 3 is the primary reason for using raw WCF - because you want the loose coupling of SOA and message-based architecture. If this is not what you want, then I recommend sticking with the data portal and WcfProxy if possible.
Are there samples somewhere using these scenarios? I'm having such a hard time executing my DataPortal_XYX methods. I currently have it setup as so for example. After the BeginGetList method is executed, it comes back to the ViewModel with the Model property unpopulated with an object. So I'm curious if I'm missing something somewhere.
Public Shared Sub BeginGetList(cb As EventHandler(Of DataPortalResult(Of T)))
Dim dp As New DataPortal(Of T)
AddHandler dp.FetchCompleted, cb
dp.BeginFetch()
End Sub
Protected Friend Overloads Sub DataPortal_Fetch(handler As LocalProxy(Of T).CompletedHandler)
RaiseListChangedEvents = False
Try
Dim client = Csla.Data.ServiceClientManager(Of ServiceReference1.WcfPortalClient, ServiceReference1.IWcfPortal).GetManager("Client").Client
AddHandler client.FetchCompleted, Sub(s, e)
Try
Dim obj As ServiceReference1.WcfResponse = e.Result
If obj IsNot Nothing Then
Array.ForEach(Of Byte)(obj.ObjectData, Sub() Add(CType(CObj(obj.ObjectData), C)))
Else
handler(Nothing, New ArgumentException("No items found"))
End If
Catch ex As Exception
handler(Nothing, ex)
End Try
End Sub
client.FetchAsync(New ServiceReference1.CriteriaRequest, Guid.NewGuid)
Catch ex As Exception
handler(Nothing, ex)
End Try
RaiseListChangedEvents = True
End Sub
If obj IsNot Nothing Then
Array.ForEach(Of Byte)(obj.ObjectData, Sub() Add(CType(CObj(obj.ObjectData), C)))
Else
handler(Nothing, New ArgumentException("No items found"))
End If
Catch ex As Exception
handler(Nothing, ex)
End Try
End Sub
You DAL callback handler must ALWAYS make sure to call the callback handler recieved as parameter in order to notify UI /Business that the async operation is completed and an object is ready.
IE:
If obj IsNot Nothing Then
Array.ForEach(Of Byte)(obj.ObjectData, Sub()
Add(CType(CObj(obj.ObjectData), C)))
handler(Me, Nothing)
Else
handler(Nothing, New ArgumentException("No items found"))
End If
Catch ex As Exception
handler(Nothing, ex)
End Try
Thank you so much johnny Bee... This was driving me crazy... I just couldn't find what I was missing.
Ok I fixed that... but the DAL is still not hitting it's breakpoint.
Hi, I am also new to WCF with CSLA, and facing the same scenario/question as you are. I read the Rocky's explantion but could not understand properly. Have you understood it? What approach you are using now? Kindly share.
Thanks in advanc,
Kalpesh Shah
Copyright (c) Marimer LLC