Hello all,
we have some problem with the combination of NHibernate, WCF and a ValidationInterceptor, and I can't find the cause of this. Hope one of you can help.
We are creating an application using a SOA architecture. The client is a web-client based on the WCSF (for now, more clients will probaply be added in the furure), the service layer are WCF services (creating using the WSSF) and the database is an oracle database.
The following is happening. When a call is being made from the client to the service layer, a new session is created and a transaction is started. The call is to save an entity. When calling the SaveOrUpdate method of the session, the validationinterceptor is being called and this validates the entity. This validationinterceptor is created using the Validation Application Block from the Enterprise Library. When the entity is validated and no errors are found, the entity is saved, a response is sent to the client, the transaction is committed and the session closed. This all works like a charm.
However, when the validation of the entity fails, the problems start. When the validation fails, we throw a custom exception. Next, the session is being closed (this always happens at the end of a service call). The exception is being handled at the client side. When a new call is started (and a new session is created with a new transaction) to get a list of some other entities, the validation of the invalid entity from the previous call is done again and fails again off course. I don't understand why this invalid entity from a different session is suddenly available in this new session. I've been looking at the new session object in debug mode and found that in this invalid entity was present in Session.SessionImpl.entityEntries.EntryList. However, I can't find how this is getting here in the new session and why.
I hope it's clear what the problem is. I can't understand why the invalid entity is present in the new session. I hope someone can point me in the direction where the invalid object is coming from and how to avoid this. This way, every time the validation fails, I have to restart the webdevelopmentserver of VS2005 of the service layer to be able to continue.
Hope someone can help. Thanks in advance,
Koen Willemse
|