Webservices support & WCF

Posts   
 
    
llblPowa
User
Posts: 41
Joined: 19-Nov-2006
# Posted on: 04-Dec-2006 16:10:27   

Hello All,

I have followed the tutorial in the LLBL Help to generate the Schema Importers and therefore be able to retrieve LLBL Entity and not Dataset on the client side.

So far it works well for Entity, but not for Collection --> with functions that return EntityCollection<Entity> I still get Dataset return value on my client...

Any cluehwere it can come from?

Cheers,

LLBLPowa

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 04-Dec-2006 16:22:39   

Hello,

could you post some samples of the generated code client and server side? And what version of llbl do you use?

llblPowa
User
Posts: 41
Joined: 19-Nov-2006
# Posted on: 04-Dec-2006 17:14:34   

Server Side:


namespace WCFServiceLibrary1
{
    [ServiceContract()]
    public interface IService1
    {
        [OperationContract]
        AbonneEntity MyOperation3(string myValue);
        [OperationContract]
        EntityCollection<AbonneEntity> GetUsersLLBLCollection(int nb);
    }

    public class service1 : IService1
    {
        public AbonneEntity MyOperation3(string myValue)
        {
            AbonneEntity abonne = new AbonneEntity("AA000004");
            return abonne;
        }

        public EntityCollection<AbonneEntity> GetUsersLLBLCollection(int nb)
        {

            EntityCollection<AbonneEntity> abonnes = new EntityCollection<AbonneEntity>(new AbonneEntityFactory());
            AbonneManager.FetchCollection<AbonneEntity>(abonnes, null, nb);
            return abonnes;
        }
        
    }
}



Client Side:


        public static void GetUsersLLBLCollection(int nb)
        {
            Service1Client myWCF = new Service1Client();
            EntityCollection<AbonneEntity> abonnes = myWCF.GetUsersLLBLCollection(nb);
            
        }

        public static void GetAbonne()
        { 
            Service1Client myWCF = new Service1Client();
            AbonneEntity abonne = myWCF.MyOperation3("AA000004");
        }

The first method will not build as abonnes is seen as a dataset.

Sample of my WCF proxy


        public Aldabra.Importation.PE.DAL.EntityClasses.AbonneEntity MyOperation3(string myValue)
        {
            ConsoleApplication2.myWCF.MyOperation3Request inValue = new ConsoleApplication2.myWCF.MyOperation3Request();
            inValue.myValue = myValue;
            ConsoleApplication2.myWCF.MyOperation3Response retVal = ((ConsoleApplication2.myWCF.IService1)(this)).MyOperation3(inValue);
            return retVal.MyOperation3Result;
        }
        
        public System.Data.DataSet GetUsersLLBLCollection(int nb)
        {
            ConsoleApplication2.myWCF.GetUsersLLBLCollectionRequest inValue = new ConsoleApplication2.myWCF.GetUsersLLBLCollectionRequest();
            inValue.nb = nb;
            ConsoleApplication2.myWCF.GetUsersLLBLCollectionResponse retVal = ((ConsoleApplication2.myWCF.IService1)(this)).GetUsersLLBLCollection(inValue);
            return retVal.GetUsersLLBLCollectionResult;
        }

in the last function, the WCF proxy generated code will use Dataset

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 04-Dec-2006 18:06:32   

Webservices don't support generics. So it won't support EntityCollection<T> returned from a method.

Frans Bouma | Lead developer LLBLGen Pro
llblPowa
User
Posts: 41
Joined: 19-Nov-2006
# Posted on: 04-Dec-2006 18:14:21   

So is there a way to do my code working? Can I return EntityCollection?

Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 04-Dec-2006 18:55:45   

llblPowa wrote:

So is there a way to do my code working? Can I return EntityCollection? Thanks.

Yes you can, the non-generic one simple_smile .

Frans Bouma | Lead developer LLBLGen Pro
llblPowa
User
Posts: 41
Joined: 19-Nov-2006
# Posted on: 04-Dec-2006 22:21:39   

Hello,

i have replaced my server with the following code:


        public EntityCollection GetUsersLLBLCollection(int nb)
        {
            DataAccessAdapter adapter = new DataAccessAdapter();
            EntityCollection abonnes = new EntityCollection(new AbonneEntityFactory());
            adapter.FetchEntityCollection(abonnes,null,50);
            return abonnes;
        }

So now, I am returning an EntityCollection. But now, from my client, I am not able to refresh the WCF server... I am having the following error (sorry, it is in french):


D:\Program Files\Microsoft Visual Studio 8\Common7\IDE\svcutil.exe /noLogo /s  /d:"C:\Documents and Settings\xxx\Local Settings\Temp\v2ful2dz.4xm" /config:"C:\Documents and Settings\xxx\Local Settings\Temp\v2ful2dz.4xm\newapp.config" /mergeConfig /out:"myWCF.cs" /language:csharp /n:*,ConsoleApplication2.myWCF "http://localhost:8080/service1"
Attempting to download metadata from 'http://localhost:8080/service1' using WS-Metadata Exchange or DISCO.
Error: Une erreur de validation s'est produite sur un sch‚ma au cours de l'exportationÿ:
    Sourceÿ: 
    Ligneÿ: 1 Colonneÿ: 1022
   Erreur de validationÿ: Le type 'http://myCompany.Importation.PE.DAL/xml/serialization:EntityCollection' n'est pas d‚clar‚.

...


which can be translated into : A validation error has occured in a schema during an exportation. ValidationError : The type "'http://myCompany.Importation.PE.DAL/xml/serialization:EntityCollection" is not declared.

Any clues?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 05-Dec-2006 10:31:00   

Did you refresh the web reference? The proxy classes have to be regenerated.

Frans Bouma | Lead developer LLBLGen Pro
llblPowa
User
Posts: 41
Joined: 19-Nov-2006
# Posted on: 05-Dec-2006 10:42:11   

Yes, I guess that I have did it? (Right click on the service references and do update).

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 05-Dec-2006 10:47:18   

The EntityCollection IS defined in the schemaimporter and webservicehelper, so I'd suggest to remove the reference, build the server and re-add the webreference. That should re-generate the classes. But frankly I have no idea why it gives this error...

The whole process is so fragile... I really wonder if they (the webservices/wcf designers) ever use this stuff themselves.

Frans Bouma | Lead developer LLBLGen Pro