How does serialization work in LLBL

Posts   
 
    
fpw2377
User
Posts: 35
Joined: 23-Feb-2007
# Posted on: 16-May-2007 00:11:23   

Hi all,

I am having a problem with web services. I have the following structure:

ApptEntity ApptWorkEntityColletion ApptWorkEntity ActiveEncounter <--- This is a property that I added to apptworkentity this is my own custom class.

I am trying to pass this apptentity to a webservice method called SaveAppt.

I keep getting:

object type cannot be converted to target type

when i make the call to the web service.

I have added lines to the user code section for GetObjectData and the other one. The wierd thing is if i sniff the call and read the xml that is being sent, my property is being serialized as a string containing the fully qualified class name. I even tried implementing ISerialible on my custom class but it never gets called. what am i doing wrong;

Here is my setup

LLBL 1.0.2005.1 Final Jan 12th, 2006 SQL Server 2000 C# 2003 client and web service Adapter

Thanks,

Frank

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 16-May-2007 08:43:04   

Please consult the manual "Using the generated code -> XML Webservices support"

fpw2377
User
Posts: 35
Joined: 23-Feb-2007
# Posted on: 16-May-2007 14:28:43   

I read the help page and I still have my question. My app was working fine before I tried adding a custom property to one of my entities. Since I added the property, it won't work. If i remove the property of set it to null before sending it works fine. It only fails when I try to set it and do the send. Here is some of my code:

this is the getobjectdata for my apptworkentity. I have put my additional serialization code in the user code section



public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("_adolescentServices", _adolescentServices);
            info.AddValue("_caseManagement", _caseManagement);
            info.AddValue("_caseManagementHistory", _caseManagementHistory);
            info.AddValue("_housingAssistanceHistory", _housingAssistanceHistory);
            info.AddValue("_housingCoordinationHistory", _housingCoordinationHistory);
            info.AddValue("_mentalHealthServicesHistory", _mentalHealthServicesHistory);
            info.AddValue("_primaryCareHistory", _primaryCareHistory);
            info.AddValue("_substanceAbuseServicesHistory", _substanceAbuseServicesHistory);
            info.AddValue("_housingAssistance", _housingAssistance);
            info.AddValue("_housingCoordination", _housingCoordination);
            info.AddValue("_mentalHealthServices", _mentalHealthServices);
            info.AddValue("_primaryCare", _primaryCare);
            info.AddValue("_substanceAbuseServices", _substanceAbuseServices);

            info.AddValue("_appointment", _appointment);

            
            // __LLBLGENPRO_USER_CODE_REGION_START GetObjectInfo
            info.AddValue("_activeEncounter", _activeEncounter, this._activeEncounter.GetType());
            info.AddValue("_inactiveEncounter", _inactiveEncounter, this._inactiveEncounter.GetType());
            // __LLBLGENPRO_USER_CODE_REGION_END
            base.GetObjectData(info, context);
        }



same for the special constructor, my code is in the user code region



        protected AppointmentWorkEntity(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            _adolescentServices = (EntityCollection)info.GetValue("_adolescentServices", typeof(EntityCollection));
            _caseManagement = (EntityCollection)info.GetValue("_caseManagement", typeof(EntityCollection));
            _caseManagementHistory = (EntityCollection)info.GetValue("_caseManagementHistory", typeof(EntityCollection));
            _housingAssistanceHistory = (EntityCollection)info.GetValue("_housingAssistanceHistory", typeof(EntityCollection));
            _housingCoordinationHistory = (EntityCollection)info.GetValue("_housingCoordinationHistory", typeof(EntityCollection));
            _mentalHealthServicesHistory = (EntityCollection)info.GetValue("_mentalHealthServicesHistory", typeof(EntityCollection));
            _primaryCareHistory = (EntityCollection)info.GetValue("_primaryCareHistory", typeof(EntityCollection));
            _substanceAbuseServicesHistory = (EntityCollection)info.GetValue("_substanceAbuseServicesHistory", typeof(EntityCollection));
            _housingAssistance = (EntityCollection)info.GetValue("_housingAssistance", typeof(EntityCollection));
            _housingCoordination = (EntityCollection)info.GetValue("_housingCoordination", typeof(EntityCollection));
            _mentalHealthServices = (EntityCollection)info.GetValue("_mentalHealthServices", typeof(EntityCollection));
            _primaryCare = (EntityCollection)info.GetValue("_primaryCare", typeof(EntityCollection));
            _substanceAbuseServices = (EntityCollection)info.GetValue("_substanceAbuseServices", typeof(EntityCollection));

            _appointment = (AppointmentEntity)info.GetValue("_appointment", typeof(AppointmentEntity));
            if(_appointment!=null)
            {
                _appointment.AfterSave+=new EventHandler(OnEntityAfterSave);
            }

            
            // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
            _activeEncounter = (EncounterDataClass)info.GetValue("_activeEncounter", typeof(EncounterDataClass));
            _inactiveEncounter = (EncounterDataClass)info.GetValue("_inactiveEncounter", typeof(EncounterDataClass));
            // __LLBLGENPRO_USER_CODE_REGION_END
        }



Now here is the class my custom property (_activeEncounter) is being set to:



[Serializable()]
    public class EncounterDataClass: ISerializable 
    {
        private bool _serviceValueSetByServiceType = false;
        protected bool _isNew = true;

        public EncounterDataClass()
        {}
        
        protected int _id = -1;
        protected DateTime _serviceDate;
        protected bool _isMom = false;
        protected bool _pelvicExam = false;
        protected bool _isPregnant = false;
        protected bool _papSmear = false;
        protected string _subType = String.Empty;
        protected string _subCategory = String.Empty;
        protected string _clientCode = String.Empty;
        protected string _performedBy  = String.Empty;
        protected string _billTo = String.Empty;
        protected decimal _serviceValue = 0;
        protected string _createdBy = String.Empty;
        protected DateTime _createdDate;
        protected string _modifiedBy = String.Empty;
        protected DateTime _modifiedDate;
        protected string _trimester = String.Empty;
        protected bool _isLocked = false;
        protected int _schedulerWorkID = 0;
        protected EncounterTypes _encounterType = EncounterTypes.NotSet;

        public bool IsNew
        {
            get
            {
                return _isNew;
            }
            set
            {
                _isNew = value;
            }
        }

        public EncounterDataClass(SerializationInfo info, StreamingContext context)
        {
            //_substanceAbuseServices = (EntityCollection)info.GetValue("_substanceAbuseServices", typeof(EntityCollection));
            this._encounterType = (EncounterTypes)Enum.Parse(typeof(EncounterTypes), info.GetInt32("encounterType").ToString());
            this._serviceValueSetByServiceType = info.GetBoolean("serviceValueSetByServiceType");
            this._isNew = info.GetBoolean("isNew");
            this._id = info.GetInt32("id");
            this._serviceDate = info.GetDateTime("serviceDate");
            this._isMom = info.GetBoolean("isMom");
            this._isPregnant = info.GetBoolean("isPregnant");
            this._papSmear = info.GetBoolean("papSmear");
            this._subType = info.GetString("subType");
            this._subCategory = info.GetString("subCategory");
            this._clientCode = info.GetString("clientCode");
            this._performedBy = info.GetString("performedBy");
            this._billTo = info.GetString("billTo");
            this._serviceValue = info.GetDecimal("serviceValue");
            this._createdBy = info.GetString("createdBy");
            this._createdDate = info.GetDateTime("createdDate");
            this._modifiedBy = info.GetString("modifiedBy");
            this._modifiedDate = info.GetDateTime("modifiedDate");
            this._isLocked = info.GetBoolean("isLocked");
            this._trimester = info.GetString("trimester");
            this._schedulerWorkID = info.GetInt32("schedulerWorkId");
        }

        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {

            info.AddValue("encounterType", (int)this._encounterType);
            info.AddValue("serviceValueSetByServiceType", this._serviceValueSetByServiceType);
            info.AddValue("isNew", this._isNew);
            info.AddValue("id", this._id);
            info.AddValue("serviceDate", this._serviceDate);
            info.AddValue("isMom", this._isMom);                
            info.AddValue("isPregnant", this._isPregnant);
            info.AddValue("papSmear", this._papSmear);
            info.AddValue("subType", this._subType);
            info.AddValue("subCategory", this._subCategory);
            info.AddValue("clientCode", this._clientCode);
            info.AddValue("performedBy", this._performedBy);
            info.AddValue("billTo", this._billTo);
            info.AddValue("serviceValue", this._serviceValue);
            info.AddValue("createdBy", this._createdBy);
            info.AddValue("createdDate", this._createdDate);
            info.AddValue("modifiedBy", this._modifiedBy);
            info.AddValue("modifiedDate", this._modifiedDate);
            info.AddValue("trimester", this._trimester);
            info.AddValue("isLocked", this._isLocked);
            info.AddValue("schedulerWorkId", this._schedulerWorkID);
            
        }
                        
        #region Public Properties
            
        public EncounterTypes EncounterType
        {
            get
            {
                return this._encounterType;
            }
            set
            {
                this._encounterType = value;
            }
        }

        public string ServiceCode
        {
            get
            {
                switch(this._encounterType)
                {
                    case EncounterTypes.NotSet:
                        return "";

                    case EncounterTypes.PrimaryCare:
                        return "PCARE";
                    
                    case EncounterTypes.AdolescentServices:
                        return "";

                    case EncounterTypes.HousingAssistance:
                        return "HOUSE";

                    case EncounterTypes.HousingCoordination:
                        return "HSCOO";

                    case EncounterTypes.MentalHealthServices:
                        return "MENT";

                    case EncounterTypes.SubstanceAbuseServices:
                        return "SUBST";

                    case EncounterTypes.CaseManagement:
                        return "CMGMT";
                    
                    default:
                        return "";
                }
            }
        }
        
        public int Id
        {
            get {return _id;}
            set {_id = value;}
        }
            
        public DateTime ServiceDate
        {
            get {return _serviceDate;}
            set {_serviceDate = value;}
        }

        public bool IsMom
        {
            get {return _isMom;}
            set {_isMom = value;}
        }

        public bool PelvicExam
        {
            get {return _pelvicExam;}
            set {_pelvicExam = value;}
        }

        public bool IsPregnant
        {
            get {return _isPregnant;}
            set {_isPregnant = value;}
        }

        public bool PapSmear
        {
            get {return _papSmear;}
            set {_papSmear = value;}
        }

        public string SubType
        {
            get {return _subType;}
            set {_subType = value;}
        }

        public string SubCategory
        {
            get {return _subCategory;}
            set {_subCategory = value;}
        }

        public string ClientCode
        {
            get {return _clientCode;}
            set {_clientCode = value;}
        }

        public string PerformedBy 
        {
            get {return _performedBy ;}
            set {_performedBy  = value;}
        }

        public string BillTo
        {
            get {return _billTo;}
            set {_billTo = value;}
        }

        public decimal ServiceValue
        {
            get {return _serviceValue;}
            set {_serviceValue = value;}
        }

        public string CreatedBy
        {
            get {return _createdBy;}
            set {_createdBy = value;}
        }

        public DateTime CreatedDate
        {
            get {return _createdDate;}
            set {_createdDate = value;}
        }

        public string ModifiedBy
        {
            get {return _modifiedBy;}
            set {_modifiedBy = value;}
        }

        public DateTime ModifiedDate
        {
            get {return _modifiedDate;}
            set {_modifiedDate = value;}
        }

        public string Trimester
        {
            get {return _trimester;}
            set {_trimester = value;}
        }

        public bool IsLocked
        {
            get {return _isLocked;}
            set {_isLocked = value;}
        }

        public int SchedulerWorkID
        {
            get {return _schedulerWorkID;}
            set {_schedulerWorkID = value;}
        }
        #endregion

        public EncounterDataClass(string serviceCode)
        {
            switch(serviceCode)
            {
                case "pcare":
                    this._encounterType = EncounterTypes.PrimaryCare;
                    break;
                case "cmgmt":
                    this._encounterType = EncounterTypes.CaseManagement;
                    break;
                case "ment":
                    this._encounterType = EncounterTypes.MentalHealthServices;
                    break;
                case "house":
                    this._encounterType = EncounterTypes.HousingAssistance;
                    break;
                case "hscoo":
                    this._encounterType = EncounterTypes.HousingCoordination;
                    break;
                case "subst":
                    this._encounterType = EncounterTypes.SubstanceAbuseServices;
                    break;
                default:
                    this._encounterType = EncounterTypes.NotSet;
                    break;
            }
        }

        public bool ServiceValueSetByServiceType
        {
            get
            {
                return _serviceValueSetByServiceType;
            }
            set
            {
                _serviceValueSetByServiceType = value;
            }
        }

    }


Me problem is how do i get llbl to serialize this custom property. Am I missing some. To my understanding by adding my private class variable to the SerializationInfo object in the GetObjectData for my apptentity it should automatically call the GetObjectData for my EncounterDataClass object and add that to the stream. What it is doing instead is pass that as this string "NCareScheduler.Data.EncounterBaseClasses.EncounterDataClass" which is the fully class name. It is never serializing the object so when the special constructor trys to fetch the property back out on the web service side I get the type casting error. Please tell me if I am just missing something simple.

Thanks, Frank

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 16-May-2007 16:02:45   

Would you please try typeof(object) instead of object.GetType()?


            // __LLBLGENPRO_USER_CODE_REGION_START GetObjectInfo
            info.AddValue("_activeEncounter", _activeEncounter, typeof(_activeEncounter));
            info.AddValue("_inactiveEncounter", _inactiveEncounter, typeof(_inactiveEncounter));
            // __LLBLGENPRO_USER_CODE_REGION_END
            base.GetObjectData(info, context);

Sometimes it makes a difference and I don't know why.

jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 16-May-2007 17:33:32   

Object.GetType() returns the runtime type, while typeof(object) returns the static type of the object. So:



Car myCar = new Porsche();

string typeName = myCar.GetType().ToString();
Console.WriteLine(typeName); //returns Porsche

typeName = typeof(myCar).ToString();
Console.WriteLine(typeName); //returns Car


Jeff...

fpw2377
User
Posts: 35
Joined: 23-Feb-2007
# Posted on: 16-May-2007 20:10:18   

Ok, I changed my code so that both places use typeof instead of gettype but I am still getting the error, here is the actual response i am getting from the web service:



<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Client</faultcode>
      <faultstring>Server was unable to read request. --&gt; There is an error in XML document (2, 3928). --&gt; Object type cannot be converted to target type.</faultstring>
      <detail />
    </soap:Fault>
  </soap:Body>
</soap:Envelope>


I am also attaching a screen shot of the xml that is being sent so you can see where active encounter is not being serialized and it is just putting a string.

jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 16-May-2007 21:34:50   

Try verifying that all of your .GetBoolean() .GetInt() .GetString() calls in your custom class are asking for the correct type. If you're serializing a variable that is of one type, you'll get an invalid cast (I believe) when retrieving it as the wrong type.

So, if you do:



//pseudocode

string _myString = string.Empty;
...
info.AddValue("_myString", _myString);

...
info.GetInt("_myString");


I think you get an invalid cast exception.

Jeff...

fpw2377
User
Posts: 35
Joined: 23-Feb-2007
# Posted on: 17-May-2007 00:03:29   

Hi Jeff,

I double checked all those conversions and they are correct. I still think the problem is before that code because the xml that is being sent to the web service does not have any of those values in it at all so I don't think that code is ever running. Its seems like it is never calling GetObjectData for my custom class. Do I need to Implement IXMLSerializible instead of ISerializible for it to call my serializing methods? or am I missing an attribute somewhere.

Thanks,

Frank

simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 17-May-2007 07:23:16   

fpw2377 wrote:

Hi Jeff,

I double checked all those conversions and they are correct. I still think the problem is before that code because the xml that is being sent to the web service does not have any of those values in it at all so I don't think that code is ever running. Its seems like it is never calling GetObjectData for my custom class. Do I need to Implement IXMLSerializible instead of ISerializible for it to call my serializing methods? or am I missing an attribute somewhere.

Thanks,

Frank

The problem in your serialization code is, I think, because you are storing the "Type" of custom property rather than the custom property itself - thats why you are seeing the string representation of the "Type" in your data.

forget the typeof()s and .GetType in GetObjectData and just store the private variable itself - serialization will take care of the rest.

Cheers Simon

fpw2377
User
Posts: 35
Joined: 23-Feb-2007
# Posted on: 17-May-2007 14:29:40   

Hi Simon,

I tried your suggestion and I still get the same error. I changed:


info.AddValue("_activeEncounter", _activeEncounter, typeof(_activeEncounter));
info.AddValue("_inactiveEncounter", _inactiveEncounter, typeof(_inactiveEncounter));

to look like this:


info.AddValue("_activeEncounter", _activeEncounter);
info.AddValue("_inactiveEncounter", _inactiveEncounter);

in the getobjectdata method. No matter what I do I always just see the full name in the xml for this property. I never calls my GetObjectData. cry For some reason it works with simple types, entities and entitycollections, what do i need to do to my class to make it work like an entity or entity collection?

Thanks, Frank

simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 17-May-2007 15:16:23   

fpw2377 wrote:

Hi Simon,

I tried your suggestion and I still get the same error. I changed:


info.AddValue("_activeEncounter", _activeEncounter, typeof(_activeEncounter));
info.AddValue("_inactiveEncounter", _inactiveEncounter, typeof(_inactiveEncounter));

to look like this:


info.AddValue("_activeEncounter", _activeEncounter);
info.AddValue("_inactiveEncounter", _inactiveEncounter);

in the getobjectdata method. No matter what I do I always just see the full name in the xml for this property. I never calls my GetObjectData. cry For some reason it works with simple types, entities and entitycollections, what do i need to do to my class to make it work like an entity or entity collection?

Thanks, Frank

OK, a quick way to check whether using normal Serialization or XmlSerialization would be to store null rather than the field value (note-don't set the field value to null!):


info.AddValue("_activeEncounter", null);
info.AddValue("_inactiveEncounter", null);

If you still get the same problem then you are using XmlSerialization not normal serialization. That being the case, you will probably need to add some attributes or other to your property and/or your new class since XmlSerialization is completely different and doesn't use GetObject etc. at all.

Can't see your screen shot since it is still pending but it might give a clue as to which Xml serialization attributes need specifying.

Also, it seems that SOAP has some additional attributes available. In .NET 2003 help, Look for "XML Serialization, attribute" which shows these documents...

"Attributes That Control XML Serialization" "Attributes That Control Encoded SOAP Serialization" "Controlling XML Serialization Using Attributes" "XML Serialization with XML Web Services"

Cheers Simon

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 17-May-2007 15:42:34   

Can't see your screen shot since it is still pending but it might give a clue as to which Xml serialization attributes need specifying.

Oops, we have missed it. It's approved now, and yeah that's xml serialization.

I think he'll have to implement IXMLSerializable. ref: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=8592

fpw2377
User
Posts: 35
Joined: 23-Feb-2007
# Posted on: 17-May-2007 16:50:05   

Ok, from reading that post and using reflector to take a quick look at the Entity2Xml method i think i found something

this case statement is falling to default when it reaches my custom property:



switch (node2.Name)
            {
                case "EntityCollectionReference":
                {
                    XmlNode firstChild = node2.FirstChild;
                    ((EntityCollectionBase2) properties[node2.Attributes["PropertyName"].Value].GetValue(this)).Xml2EntityCollection(firstChild, processedObjectIDs, nodeEntityReferences);
                    continue;
                }
                case "EntityReference":
                {
                    if (node2.ChildNodes.Count > 0)
                    {
                        XmlNode node4 = node2.SelectSingleNode(prefix + "ProcessedObjectReference", nsmgr);
                        if (node4 == null)
                        {
                            break;
                        }
                        NodeEntityReference reference = new NodeEntityReference();
                        reference.ObjectID = new Guid(node4.Attributes["ObjectID"].Value);
                        reference.PropertyHoldingInstance = this;
                        reference.IsCollectionAdd = false;
                        reference.ReferencingProperty = properties[node2.Attributes["PropertyName"].Value];
                        nodeEntityReferences.Add(reference);
                    }
                    continue;
                }
                case "Validator":
                    goto Label_0375;

                case "EntityValidator":
                {
                    string text6 = node2.Attributes["Assembly"].Value;
                    if (text6 != "Unknown")
                    {
                        Assembly assembly3 = Assembly.Load(text6);
                        string text7 = node2.Attributes["Type"].Value;
                        this.EntityValidatorToUse = (IEntityValidator) assembly3.CreateInstance(text7);
                    }
                    continue;
                }
                case "ConcurrencyPredicateFactory":
                {
                    string text8 = node2.Attributes["Assembly"].Value;
                    if (text8 != "Unknown")
                    {
                        Assembly assembly4 = Assembly.Load(text8);
                        string text9 = node2.Attributes["Type"].Value;
                        this.ConcurrencyPredicateFactoryToUse = (IConcurrencyPredicateFactory) assembly4.CreateInstance(text9);
                    }
                    continue;
                }
                case "Fields":
                {
                    this._fields.ReadXml(node2);
                    continue;
                }
                case "SavedFieldSets":
                {
                    XmlNodeList childNodes = node2.ChildNodes;
                    if (childNodes.Count <= 0)
                    {
                        goto Label_0569;
                    }
                    this._savedFields = new Hashtable();
                    foreach (XmlNode node6 in childNodes)
                    {
                        XmlNode fieldsElement = node6.SelectSingleNode(prefix + "Fields", nsmgr);
                        IEntityFields2 fields = (IEntityFields2) ((EntityFields2) this._fields).Clone();
                        fields.ReadXml(fieldsElement);
                        string text10 = node6.Attributes["Name"].Value;
                        this._savedFields[text10] = fields;
                    }
                    continue;
                }
                case "IsDirty":
                {
                    this.Fields.IsDirty = Convert.ToBoolean(node2.InnerText);
                    continue;
                }
                case "EntityState":
                    innerText = node2.InnerText;
                    goto Label_05B0;

                default:
                    goto Label_062D;
            }



which goes to this code:



Label_062D:
            typeName = string.Empty;
            if (node2.Attributes.GetNamedItem("Type") == null)
            {
                typeName = properties[node2.Name].PropertyType.UnderlyingSystemType.FullName.ToString();
            }
            else
            {
                typeName = node2.Attributes["Type"].Value;
            }
            string xmlValue = node2.InnerText;
            properties[node2.Name].SetValue(this, helper.XmlValueToObject(typeName, xmlValue));



which looks like it just sets the node to the objects classname. Now if I am right is there anyway for me to fix this? because unless my nodename matchs one of those, it won't know how to serialize/deserialize my classes.

Thanks,

Frank

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 17-May-2007 17:03:53   

That's correct, and serialization of custom objects into the XML is currently not supported, it will be added to v2.x the upgrade that's currently in development as it needs an architectural change to be able to do so. I'm sorry for this inconvenience.

If you absolutely MUST, you've to alter the runtime lib sourcecode and add the code in there. If you want to EXCLUDE your objects, please place [XmlIgnore()] attributes on top of the properties, they'll be ignored.

Btw, all work you've done with info etc. is for binary serialization, that's something completely different, hence why we were on the wrong track helping you.

Frans Bouma | Lead developer LLBLGen Pro
fpw2377
User
Posts: 35
Joined: 23-Feb-2007
# Posted on: 17-May-2007 17:12:45   

Ok, from reading that post and using reflector to take a quick look at the Entity2Xml method i think i found something

this case statement is falling to default when it reaches my custom property:



switch (node2.Name)
            {
                case "EntityCollectionReference":
                {
                    XmlNode firstChild = node2.FirstChild;
                    ((EntityCollectionBase2) properties[node2.Attributes["PropertyName"].Value].GetValue(this)).Xml2EntityCollection(firstChild, processedObjectIDs, nodeEntityReferences);
                    continue;
                }
                case "EntityReference":
                {
                    if (node2.ChildNodes.Count > 0)
                    {
                        XmlNode node4 = node2.SelectSingleNode(prefix + "ProcessedObjectReference", nsmgr);
                        if (node4 == null)
                        {
                            break;
                        }
                        NodeEntityReference reference = new NodeEntityReference();
                        reference.ObjectID = new Guid(node4.Attributes["ObjectID"].Value);
                        reference.PropertyHoldingInstance = this;
                        reference.IsCollectionAdd = false;
                        reference.ReferencingProperty = properties[node2.Attributes["PropertyName"].Value];
                        nodeEntityReferences.Add(reference);
                    }
                    continue;
                }
                case "Validator":
                    goto Label_0375;

                case "EntityValidator":
                {
                    string text6 = node2.Attributes["Assembly"].Value;
                    if (text6 != "Unknown")
                    {
                        Assembly assembly3 = Assembly.Load(text6);
                        string text7 = node2.Attributes["Type"].Value;
                        this.EntityValidatorToUse = (IEntityValidator) assembly3.CreateInstance(text7);
                    }
                    continue;
                }
                case "ConcurrencyPredicateFactory":
                {
                    string text8 = node2.Attributes["Assembly"].Value;
                    if (text8 != "Unknown")
                    {
                        Assembly assembly4 = Assembly.Load(text8);
                        string text9 = node2.Attributes["Type"].Value;
                        this.ConcurrencyPredicateFactoryToUse = (IConcurrencyPredicateFactory) assembly4.CreateInstance(text9);
                    }
                    continue;
                }
                case "Fields":
                {
                    this._fields.ReadXml(node2);
                    continue;
                }
                case "SavedFieldSets":
                {
                    XmlNodeList childNodes = node2.ChildNodes;
                    if (childNodes.Count <= 0)
                    {
                        goto Label_0569;
                    }
                    this._savedFields = new Hashtable();
                    foreach (XmlNode node6 in childNodes)
                    {
                        XmlNode fieldsElement = node6.SelectSingleNode(prefix + "Fields", nsmgr);
                        IEntityFields2 fields = (IEntityFields2) ((EntityFields2) this._fields).Clone();
                        fields.ReadXml(fieldsElement);
                        string text10 = node6.Attributes["Name"].Value;
                        this._savedFields[text10] = fields;
                    }
                    continue;
                }
                case "IsDirty":
                {
                    this.Fields.IsDirty = Convert.ToBoolean(node2.InnerText);
                    continue;
                }
                case "EntityState":
                    innerText = node2.InnerText;
                    goto Label_05B0;

                default:
                    goto Label_062D;
            }



which goes to this code:



Label_062D:
            typeName = string.Empty;
            if (node2.Attributes.GetNamedItem("Type") == null)
            {
                typeName = properties[node2.Name].PropertyType.UnderlyingSystemType.FullName.ToString();
            }
            else
            {
                typeName = node2.Attributes["Type"].Value;
            }
            string xmlValue = node2.InnerText;
            properties[node2.Name].SetValue(this, helper.XmlValueToObject(typeName, xmlValue));



which looks like it just sets the node to the objects classname. Now if I am right is there anyway for me to fix this? because unless my nodename matchs one of those, it won't know how to serialize/deserialize my classes.

Thanks,

Frank

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 17-May-2007 17:15:06   

You posted the same message twice?

Frans Bouma | Lead developer LLBLGen Pro
fpw2377
User
Posts: 35
Joined: 23-Feb-2007
# Posted on: 17-May-2007 17:18:41   

Thank you all for the help, I will try to find another way to pass the info i need to the webservice, I would edit source to make it work but that would mean I would have to repush that to all the clients. Look forward to that feature in the 2.x stuff.

Thanks,

Frank

P.S. Sorry for the double post, i was having internet connection issues.

fpw2377
User
Posts: 35
Joined: 23-Feb-2007
# Posted on: 18-May-2007 15:59:28   

Just to let everyone know I ended up cheating. The activeencounter property i was trying to pass to the webservice was just a class that stored some values so that i would know what kind of encounter entity to create at the webservice. Since my class could not be serialized I just created a new table with the same fields as my class and made an entity from it. I use that entity now instead of my class and it will serialize just fine. Really looking forward to the new features in 2.x.

Thanks,

Frank