Collection serialization and SOAP
Posted by Dave Hrycyszyn 10th March 2006 in Head LabsThe other day I was using SOAP and C# to return an array of objects from a web service to a Flash client. On the server, each object of type SiteSectionEntity has a property ("Children") which is an IList of SiteSectionEntities. It's a pretty normal recursive structure, one level deep. My trouble was that the Children objects were being serialized like this:
-
true Some text here. ...more attributes here...
I didn't want that. I tried putting an attribute declaration on to the Children property of the C# class, but it didn't quite work:
-
[XmlElement( "Children", typeof(SiteSectionEntity))]</p> <p>public IList Children {</p> <p> get { return children; }<br /> set { children = value; }</p> <p>}</p> <p>
This resulted in a nearly-working SOAP response (it was almost correct but I needed an ArrayOfChildren).
After some head-scratching, I figured it out.
-
</p> <p>[XmlArray("Children")] [XmlArrayItem("SiteSectionEntity",typeof(SiteSectionEntity))]</p> <p>public IList Children {</p> <p> get { return children; }<br /> set { children = value; }</p> <p>}
This results in the structure I wanted, and my Flash client was happy. It looks like this:
-
− − true images/florida1.JPG test 2 90 84 0 0 0 1 13 − true images/florida3.JPG test 1 89 84 0 0 0 1 15 true This is a test to see whether a new menu order of the correct magnitude gets generated when a new object is created. images/carpa.JPG menu order test 2 84 -1 200 100 100 1 1
Hopefully this will help out somebody else who runs into the same problem.
2 Responses to “Collection serialization and SOAP”
Leave a Reply
Search
Categories
- Thoughts
(19)
- News
(30)
- Head Labs
(13)
- Project launch
(10)
- Life at Head
(10)
Monthly Archives
- January 2009 (1)
- December 2008 (3)
- November 2008 (4)
- September 2008 (1)
- August 2008 (1)
- July 2008 (1)
- June 2008 (1)
- May 2008 (2)
- March 2008 (1)
- February 2008 (1)
- January 2008 (1)
- November 2007 (2)
- August 2007 (1)
- May 2007 (2)
- April 2007 (5)
- March 2007 (11)
- February 2007 (10)
- January 2007 (4)
- November 2006 (2)
- September 2006 (4)
- August 2006 (1)
- July 2006 (1)
- June 2006 (3)
- May 2006 (1)
- April 2006 (3)
- March 2006 (7)
- February 2006 (5)
- January 2006 (1)
- November 2005 (1)
Do you know how to compiler Flash in C#?
Thanks
Hm, maybe my post wasn’t clear.
I was using a C# web application on the server to return data to the Flash movie via a SOAP web service. The problem was that the data wasn’t coming back in the format I wanted it to.
As far as I know, there is no way to write anything in C# and end up with a compiled SWF. There are only two compilers that will generate SWF bytecode:
*first, the Macromedia compiler that comes with Flash
*second, the MTASC compiler from http://www.mtasc.org This compiler is written in the OCAML language, but you use it just like you would the Macromedia one (sort of).
Actionscript 2 is very much like C# in its syntax, though, so if you are a C# coder you wouldn’t have much trouble learning the language, although the component architecture and general environment can be a little crazy sometimes.