Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Problem with Relations mapping exposed in a Web Service
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Joil  
View profile  
 More options Mar 29 2012, 11:54 pm
From: Joil <j...@joil.cl>
Date: Thu, 29 Mar 2012 20:54:32 -0700 (PDT)
Local: Thurs, Mar 29 2012 11:54 pm
Subject: Problem with Relations mapping exposed in a Web Service

Hi people, I have a problem with Relations mapping exposed in a Web Service

Model

[ActiveRecord]
    public class Ticket : ActiveRecordValidationBase<Ticket>
    {
        private IList _followup = new ArrayList();        

        [PrimaryKey(PrimaryKeyType.Native)]
        public int Id {
            get; set;
        }
        ...
        ...
        [HasMany(typeof(Followup), Inverse = true, Table="Followup",
ColumnKey="TicketId")]
        public IList Followups
        {
            get { return _followup; }
            set { _followup = value; }
        }
    }

[ActiveRecord]
    public class Followup : ActiveRecordValidationBase<Followup>
    {
        private Ticket _ticket;

        [PrimaryKey(PrimaryKeyType.Native)]
        public int Id {
            get; set;
        }
        ...
        ...
        [BelongsTo("TicketId")]
        public Ticket TicketRef
        {
            get { return _ticket; }
            set { _ticket = value; }
        }
    }

Web Serbice

    public class ws : System.Web.Services.WebService
    {
        [WebMethod()]
        public Ticket[] ListAllTicket() {
            return (Ticket[]) Ticket.FindAll(typeof(Ticket));
        }
    }    

Error Invoke WebMethod, output :

500 - Internal Server Error
System.InvalidOperationException: There was an error generating the XML
document. ---> System.InvalidOperationException: A circular reference was
detected while serializing an object of type Ticket
  at System.Xml.Serialization.XmlSerializationWriter.WriteStartElement
(System.String name, System.String ns, System.Object o, Boolean
writePrefixed, ICollection namespaces) [0x00000] in <filename unknown>:0
  at System.Xml.Serialization.XmlSerializationWriter.WriteStartElement
(System.String name, System.String ns, System.Object o, Boolean
writePrefixed) [0x00000] in <filename unknown>:0
  at System.Xml.Serialization.XmlSerializationWriter.WriteStartElement
(System.String name, System.String ns, System.Object o) [0x00000] in
<filename unknown>:0
  at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObject
(System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob,
System.String element, System.String namesp, Boolean isNullable, Boolean
needType, Boolean writeWrappingElem) [0x00000] in <filename unknown>:0
  at
System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteMemberEleme nt
(System.Xml.Serialization.XmlTypeMapElementInfo elem, System.Object
memberValue) [0x00000] in <filename unknown>:0
  at
System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteElementMemb ers
(System.Xml.Serialization.ClassMap map, System.Object ob, Boolean
isValueList) [0x00000] in <filename unknown>:0
  at
System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectEleme ntElements
(System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob)
[0x00000] in <filename unknown>:0
  at
System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectEleme nt
(System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob,
System.String element, System.String namesp) [0x00000] in <filename
unknown>:0
  at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObject
(System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob,
System.String element, System.String namesp, Boolean isNullable, Boolean
needType, Boolean writeWrappingElem) [0x00000] in <filename unknown>:0
  at
System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteMemberEleme nt
(System.Xml.Serialization.XmlTypeMapElementInfo elem, System.Object
memberValue) [0x00000] in <filename unknown>:0
  at
System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteListContent
(System.Object container, System.Xml.Serialization.TypeData listType,
System.Xml.Serialization.ListMap map, System.Object ob,
System.Text.StringBuilder targetString) [0x00000] in <filename unknown>:0
  at
System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteMemberEleme nt
(System.Xml.Serialization.XmlTypeMapElementInfo elem, System.Object
memberValue) [0x00000] in <filename unknown>:0
  at
System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteElementMemb ers
(System.Xml.Serialization.ClassMap map, System.Object ob, Boolean
isValueList) [0x00000] in <filename unknown>:0
  at
System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectEleme ntElements
(System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob)
[0x00000] in <filename unknown>:0
  at
System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectEleme nt
(System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob,
System.String element, System.String namesp) [0x00000] in <filename
unknown>:0
  at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObject
(System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob,
System.String element, System.String namesp, Boolean isNullable, Boolean
needType, Boolean writeWrappingElem) [0x00000] in <filename unknown>:0
  at
System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteMemberEleme nt
(System.Xml.Serialization.XmlTypeMapElementInfo elem, System.Object
memberValue) [0x00000] in <filename unknown>:0
  at
System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteListContent
(System.Object container, System.Xml.Serialization.TypeData listType,
System.Xml.Serialization.ListMap map, System.Object ob,
System.Text.StringBuilder targetString) [0x00000] in <filename unknown>:0
  at
System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteListElement
(System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob,
System.String element, System.String namesp) [0x00000] in <filename
unknown>:0
  at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObject
(System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob,
System.String element, System.String namesp, Boolean isNullable, Boolean
needType, Boolean writeWrappingElem) [0x00000] in <filename unknown>:0
  at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteRoot
(System.Object ob) [0x00000] in <filename unknown>:0
  at System.Xml.Serialization.XmlSerializer.Serialize (System.Object o,
System.Xml.Serialization.XmlSerializationWriter writer) [0x00000] in
<filename unknown>:0
  at System.Xml.Serialization.XmlSerializer.Serialize (System.Xml.XmlWriter
writer, System.Object o, System.Xml.Serialization.XmlSerializerNamespaces
namespaces) [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Xml.Serialization.XmlSerializer.Serialize (System.Xml.XmlWriter
writer, System.Object o, System.Xml.Serialization.XmlSerializerNamespaces
namespaces) [0x00000] in <filename unknown>:0
  at System.Xml.Serialization.XmlSerializer.Serialize (System.Xml.XmlWriter
xmlWriter, System.Object o) [0x00000] in <filename unknown>:0
  at System.Web.Services.Protocols.XmlReturnWriter.Write
(System.Web.HttpResponse response, System.IO.Stream outputStream,
System.Object returnValue) [0x00000] in <filename unknown>:0
  at
System.Web.Services.Protocols.HttpSimpleWebServiceHandler.ProcessRequest
(System.Web.HttpContext context) [0x00000] in <filename unknown>:0

Any idea, how to fix ?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Tarasoff  
View profile   Translate to Translated (View Original)
 More options Mar 30 2012, 12:18 am
From: Eric Tarasoff <eric.taras...@gmail.com>
Date: Thu, 29 Mar 2012 21:18:31 -0700
Local: Fri, Mar 30 2012 12:18 am
Subject: Re: Problem with Relations mapping exposed in a Web Service

You might not like this answer but in situations like this, or even in Ajax
situations, we use DTOs. Serializing complex object graphs (or even not so
complex ones) always seems to be problematic.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joil  
View profile  
 More options Apr 4 2012, 2:24 pm
From: Joil <j...@joil.cl>
Date: Wed, 4 Apr 2012 11:24:06 -0700 (PDT)
Local: Wed, Apr 4 2012 2:24 pm
Subject: Re: Problem with Relations mapping exposed in a Web Service

El viernes 30 de marzo de 2012 01:18:31 UTC-3, Eric Tarasoff escribió:

> You might not like this answer but in situations like this, or even in
> Ajax situations, we use DTOs. Serializing complex object graphs (or even
> not so complex ones) always seems to be problematic.

you have any example to use DTO, link, code...with ActiveRecord

thanks

El viernes 30 de marzo de 2012 01:18:31 UTC-3, Eric Tarasoff escribió:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jose Pino  
View profile  
 More options Mar 31 2012, 12:14 am
From: Jose Pino <j...@joil.cl>
Date: Sat, 31 Mar 2012 01:14:20 -0300
Local: Sat, Mar 31 2012 12:14 am
Subject: Re: Problem with Relations mapping exposed in a Web Service
El jue, 29-03-2012 a las 21:18 -0700, Eric Tarasoff escribió:

> You might not like this answer but in situations like this, or even in
> Ajax situations, we use DTOs. Serializing complex object graphs (or
> even not so complex ones) always seems to be problematic.

you have any example to use DTO, link, code...with ActiveRecord

thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Tarasoff  
View profile  
 More options Apr 4 2012, 5:54 pm
From: Eric Tarasoff <eric.taras...@gmail.com>
Date: Wed, 4 Apr 2012 14:54:50 -0700
Local: Wed, Apr 4 2012 5:54 pm
Subject: Re: Problem with Relations mapping exposed in a Web Service

You don't really need a hard code example? Basically, imagine something
like:

var myActiveRecordObjectThatWontSerialize = GetNewInstance();
var simpleDTO = new SimpleDTOThatSerializes();

simpleDTO.Field1 = myActiveRecordObjectThatWontSerialize.Field1;
simpleDTO.Field2 =
myActiveRecordObjectThatWontSerialize.NestedObject.Field2;

etc...you could also possibly use AutoMapper or something like that to kind
of automate how that gets done.

SimpleDTOThatSerializes is something like:

public class SimpleDTOThatSerializes
{
      public string Field1 { get; set; }
      public string Field2 { get; set; }

}

Hope that helps...

Eric

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »