passing EntityCollection with WCF

Posts   
1  /  2
 
    
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39615
Joined: 17-Aug-2003
# Posted on: 07-Mar-2007 16:50:46   

When you pass the collection which gives the error, it has multiple types in it, e.g. persons and locations? The thing is that the XML is restored into objects of the type of the factory. If a person entity is encountered, this thus isn't restorable in a contact entity as that's the supertype.

Frans Bouma | Lead developer LLBLGen Pro
bakman
User
Posts: 14
Joined: 07-Mar-2007
# Posted on: 07-Mar-2007 17:29:05   

Hi

Well in this particular test, all entities are actually PersonEntities, but yes, the idea was that I could query the DB for any type of Contact either Location or Person or a mix thereof.

As far as I can see when retrieving from the DB the ContactEntityFactory figures out the proper type and creates it, but if I understand you correctly that is not the case when rebuilding the object graph from XML.

If that is the case, do you have any suggestions on how to accomplish this?

I am not ruling out the option of specifying the proper factory as it is a perfectly valid solution and might be what I am going for in the end, but I was investigating my options with WCF and LLBLGen and found this solution interesting.

Thank you for your feedback!

Lau

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39615
Joined: 17-Aug-2003
# Posted on: 07-Mar-2007 18:37:22   

For now, specify the proper factory, that will make your code work now.

I'll take your suggestion with me when I'll dig into the WCF code for v2.1, so I'll try to address it there. You have a point that the factory could determine the types again, however with XML it's pretty complicated compared to db rows where all that has to be done is checking for NULL values but perhaps I can sneak in a type id somewhere simple_smile

Frans Bouma | Lead developer LLBLGen Pro
bakman
User
Posts: 14
Joined: 07-Mar-2007
# Posted on: 08-Mar-2007 08:15:49   

Hi

I will do that.

And thank you again for your quick response.

Regards Lau

llblPowa
User
Posts: 41
Joined: 19-Nov-2006
# Posted on: 15-Mar-2007 13:53:56   

Hello,

Ok, implementing your example works fine (using interface contracts).

But, now, I am trying to use the proxy classes generated by VS2005 : Right click on references, then select [add service reference].

Doing this:


            HelloServiceClient p = new HelloServiceClient();
            IEntity2 e = (IEntity2)p.GetPublication();

I am having the following error:

Unable to cast object of type 'System.Xml.XmlNode[]' to type 'SD.LLBLGen.Pro.ORMSupportClasses.IEntity2'.

Did I miss anything? (during the llbl code generation, I have checked the 3 schema importer tasks, as well as the WebserviceHelperClassGenerator).

Thanks,

Silat

bakman
User
Posts: 14
Joined: 07-Mar-2007
# Posted on: 15-Mar-2007 14:25:01   

Hi

I don't really use the VS2005 generated proxy classes - I like to know the exact interface at both ends.

For example for an interface IEcho:


[ServiceContract]
public interface IEchoService
{
    [OperationContract]
    string Echo(string message);
}

I create a client to go with it (of cause this only works if it is .NET in both ends).


public class EchoClient : ClientBase<IEchoService>, IEchoService
{
    public EchoClient()
    {
        
    }

    public string Echo(string message)
    {
        return this.Channel.Echo(message);
    }
}

In this way I do not have to worry about the generated proxies...

The client is configured in the App.config:


    <system.serviceModel>
        <client>
            <endpoint address="net.tcp://localhost:9000/EchoService"
                      binding="netTcpBinding"
                      contract="Something.Interface.IEchoService" />
        </client>
    </system.serviceModel>

Regards Lau

llblPowa
User
Posts: 41
Joined: 19-Nov-2006
# Posted on: 15-Mar-2007 16:13:22   

Yes, I understand and the example works fine :-)

However, I am asking because, I would like to use the guidance tool that generate Smart Proxy from WCF services for SCSF (MS SmartClient Software Factory).

btw I have not yet tried that one, only the default one in VS2005 (-> add service reference).

It should work? no? Because if this step does not work then I will have no chance to integrate my llbl project with SCSF using WCF and benefit from their disconnected agent framework.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39615
Joined: 17-Aug-2003
# Posted on: 17-Mar-2007 13:53:54   

If you're using WCF, kick out the proxies, you don't need them. If you're using .NET 2.0 webservices, use the proxies. The proxies are really bad, as they generate NEW types on the client for the types returned by the service. This is NOT what you want, as the types returned by the service are already known by the client, namely the generated entities.

Frans Bouma | Lead developer LLBLGen Pro
1  /  2