webservice or wcf as an adapter

Posts   
 
    
vairam2008
User
Posts: 86
Joined: 11-Mar-2008
# Posted on: 18-Mar-2008 00:56:23   

I am trying to use webservice or wcf as an adapter where each business object has a web service.

1.the data is obtained for the entire business object in serialized form, 2.deserialized to business object containing entity objects 3.changes are made 4. serialized back with isdirty state to the webservice update method that will save the changes.

How to do this as an adapter way that the code logic for the adapter is very minimal & generic for all business objects & the UI & business object itself doesn't have to know the source of the data (database or webservice).

I need some explanation of how this works in Gen Pro. thanks

vairam2008
User
Posts: 86
Joined: 11-Mar-2008
# Posted on: 18-Mar-2008 02:05:31   

what does schema importer does?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 18-Mar-2008 10:03:42   

vairam2008 wrote:

what does schema importer does?

Can I ask you a question? Have you checked out our 500+ page manual? simple_smile Most of your questions are in there, like this one. (Using the generated code -> Adapter -> Distributed systems -> XML webservices )

We also have some very good example applications available like how to use llblgen pro with wcf. You'll see most of your questions are already answered in the examples, docs or FAQ (try the search on this forum wink ).

Frans Bouma | Lead developer LLBLGen Pro
vairam2008
User
Posts: 86
Joined: 11-Mar-2008
# Posted on: 18-Mar-2008 20:19:48   

Can I ask you a question? Have you checked out our 500+ page manual? Most of your questions are in there, like this one. (Using the generated code -> Adapter -> Distributed systems -> XML webservices )

I am reading & going through it. This is the understanding of how it works I have as of now.

Obviously I haven't mastered it or ignore my lack of understanding & knowledge, lead me there of, your pointer to help file infact did help.

I was looking in the forum, I last the thread id, but the summary of it was somebody was trying to create a DataAccessAdapter for webservice & it was told that webservice cannot be perceived as a DataAccessAdapter.

Let me explain my scenario I have & what I am planning to do.

I have an application where I want it to work with a direct database (when it is available to connect directly) or to a web service. I am requiring to write a generic code so that I don't have to do custom logic in every place to put a switch if connected to database or web service.

So the approach one would do is as follows.

I create a webservice specific code in a project as follows in the client side. MyProjectDataAccess.Update(UnitOfWork2 uow) { If connecting to Database Then //using new adapter: uow.Commit(adapter,true) else uow.GetObjectData myCommonWebservice.Update(serializeddata)

on the webservice side Update(UnitofWork2 uow) { try { using adapter, uow.Commit(adapter, true) } catch { process error message } }

The pieces I am in process to learn is how to make it use binary for WCF communication. & if this approach is correct?

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 20-Mar-2008 18:31:59   

At some point you have to make the decision to which code to connect to: the WCF service, so you can simply send over the data and with it perhaps the command code/messages, OR to the db directly and you've to do the work yourself.

This is effectively creating 2 times the same code: namely the service has the code to work with the data and your application has it too. It's however not said that the code looks the same.

So IMHO, you're better off which just the service, and contact that one, or write a library which is used by both the application and the service and the service is a wrapper around the library and you call the library directly in your application if you want to connect directly. To avoid a lot of if/else clauses in the code, you then should work with two assemblies which are used by your application and which implement the same interface: if you work locally, you load the assembly which handles local, direct connects. If you work with the service, you load the assembly which handles connects with the service.

Frans Bouma | Lead developer LLBLGen Pro
vairam2008
User
Posts: 86
Joined: 11-Mar-2008
# Posted on: 20-Mar-2008 20:31:42   

If I make that UnitOfWork2 will be used for updating instead of calling update function directly on the entity. Since Unitofwork2 can be serialized, is it not one webservice or connection point is sufficient? Same is the case for getting the BusinessObject. If I have a common ancestor for BusinessObject I just need one method GetData [WebMethod] GetData(BusinessObject instanceBo)

That connection point will have UnitOfWork2 as the input parameter like stated before? So, I really don't have to create a wrapper for every business object and/or entities required serialization?

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 20-Mar-2008 21:18:05   

A unitOfWork isn't serializable over a webservice (it's not serializable to XML). This is due to the fact that proper webservice design principles dictate that you should write message based services, not low-level tier-based services (which tend to be very chatty).

a unitofwork is serializable over remoting.

Frans Bouma | Lead developer LLBLGen Pro