IEntity2 not serializable,

Posts   
 
    
craigmain
User
Posts: 22
Joined: 17-Apr-2005
# Posted on: 20-Apr-2005 21:56:01   

Hi,

I get the following error when I try to create the following web method. I understand that the EntityCollections are serializable, I am using the web service from .NET to .NET so this should surely not be a problem.

What am I doing wrong.

        [WebMethod]
        public EntityCollection Vehicles() {
            EntityCollection collection = adapter.FillCollection(new EntityCollection(new VehicleGroupEntityFactory()), null);
            return collection;
        }


[NotSupportedException: Cannot serialize interface SD.LLBLGen.Pro.ORMSupportClasses.IEntity2.]
   System.Xml.Serialization.TypeScope.ImportTypeDesc(Type type, Boolean canBePrimitive, MemberInfo memberInfo)
   System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference)
   System.Xml.Serialization.TypeScope.GetTypeDesc(Type type)
   System.Xml.Serialization.TypeScope.ImportTypeDesc(Type type, Boolean canBePrimitive, MemberInfo memberInfo)
   System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference)
   System.Xml.Serialization.TypeScope.GetTypeDesc(Type type)
   System.Xml.Serialization.XmlReflectionImporter.ImportMemberMapping(XmlReflectionMember xmlReflectionMember, String ns, XmlReflectionMember[] xmlReflectionMembers)
   System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement)

[InvalidOperationException: There was an error reflecting 'VehiclesResult'.]
   System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement)
   System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(String elementName, String ns, XmlReflectionMember[] members, Boolean hasWrapperElement)
   System.Web.Services.Protocols.SoapReflector.ImportMembersMapping(XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter, Boolean serviceDefaultIsEncoded, Boolean rpc, SoapBindingUse use, SoapParameterStyle paramStyle, String elementName, String elementNamespace, Boolean nsIsDefault, XmlReflectionMember[] members, Boolean validate)
   System.Web.Services.Protocols.SoapReflector.ReflectMethod(LogicalMethodInfo methodInfo, Boolean client, XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter, String defaultNs)

[InvalidOperationException: Method llProWebService.Vehicles can not be reflected.]
   System.Web.Services.Protocols.SoapReflector.ReflectMethod(LogicalMethodInfo methodInfo, Boolean client, XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter, String defaultNs)
   System.Web.Services.Description.SoapProtocolReflector.ReflectMethod()
   System.Web.Services.Description.ProtocolReflector.ReflectBinding(ReflectedBinding reflectedBinding)
   System.Web.Services.Description.ProtocolReflector.Reflect()
   System.Web.Services.Description.ServiceDescriptionReflector.ReflectInternal(ProtocolReflector[] reflectors)
   System.Web.Services.Description.ServiceDescriptionReflector.Reflect(Type type, String url)
   System.Web.Services.Protocols.DocumentationServerType..ctor(Type type, String uri)
   System.Web.Services.Protocols.DocumentationServerProtocol.Initialize()
   System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
   System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)

Answer
User
Posts: 363
Joined: 28-Jun-2004
# Posted on: 20-Apr-2005 22:32:19   

Are you using the newest beta? Up until the beta the the entities didnt implement IXmlSerializable so you couldnt call them directly in a webservice like you are doing you had to make the function return a string, then return entity.writexml()

In the newest beta you should be able to do what you are doing, but you have to do kinda a hack on the client end since it thinks your a returning datasets. In your proxy that the wsdl generate you have to change all the datasets to entity objects.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 20-Apr-2005 23:24:09   

Indeed, Answer simple_smile

Serializable is for remoting, webservices use xmlserializer which can't deal with that. In 1.0.2004.2 this is solved, in 1.0.2004.1, you have to manually produce XML using WriteXml(), and return the XmlNode.

Frans Bouma | Lead developer LLBLGen Pro
craigmain
User
Posts: 22
Joined: 17-Apr-2005
# Posted on: 20-Apr-2005 23:33:30   

Hi,

Thanks guys, I will try the new beta.

Regards Craig.