UnitOfWork2 in WCF

Posts   
 
    
ianvink
User
Posts: 394
Joined: 15-Dec-2006
# Posted on: 08-Oct-2007 02:23:08   

I have written a Hello world app that nicely moved Entites around from client to server and back.

Is there anything special to setting up a WCF contract to accept a UnitofWork2 from a client?

My contract is:

    
    [ServiceContract]
    [ServiceKnownType(typeof(EntityCollection<CustomerEntity>))]
    [ServiceKnownType(typeof(UnitOfWork2))]
    public interface ICustomer
    {
        [OperationContract]
        EntityCollection<CustomerEntity> GetCustomers();

        [OperationContract]
        void Update(UnitOfWork2 Unit);

    }

When I pass in my UnitOfWork2 like this:

UnitOfWork2 unit = new UnitOfWork2();
unit.AddForSave(myCustomrEntity);
serverCustomer.Update(unit);

I get this error:

There was an error while trying to serialize parameter http://tempuri.org/:Unit. The InnerException message was 'Type 'System.Collections.Generic.List`1[[SD.LLBLGen.Pro.ORMSupportClasses.UnitOfWorkElement2, SD.LLBLGen.Pro.ORMSupportClasses.NET20, Version=2.5.0.0, Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27]]' with data contract name 'ArrayOfUnitOfWorkElement2:http://schemas.datacontract.org/2004/07/SD.LLBLGen.Pro.ORMSupportClasses' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details.

I do have **[ServiceKnownType(typeof(UnitOfWork2))] **in the contract.

Ideas?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 08-Oct-2007 04:35:57   

At first, could you elaborate more on why do you want to pass UOW in this scenario? Will you use Webservices or remoting? Here's one of the typical debates about serializing objects across webservices: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=8174

David Elizondo | LLBLGen Support Team
ianvink
User
Posts: 394
Joined: 15-Dec-2006
# Posted on: 08-Oct-2007 13:59:39   

Remoting.

Client and service will run on WCF machines.

binding="netTcpBinding"

Ian

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 08-Oct-2007 17:46:22   

What about the inner exception, was it empty?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 12-Oct-2007 10:45:45   

Also, are you sure you're using remoting? because it looks like xml serialization to me, as remoting throws much more harsher exceptions. (Unitofwork classes aren't serializable over xml by default)

Frans Bouma | Lead developer LLBLGen Pro