Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Applying XmlArrayAttribute to the return value that returns an array of complex objects???

Reply
Thread Tools

Applying XmlArrayAttribute to the return value that returns an array of complex objects???

 
 
Bob Rock
Guest
Posts: n/a
 
      06-04-2004
Hello,

I read that XmlArrayAttribute may be applyed to "the return value that
returns an array of complex objects" but I don't understand how.
I'd like it to apply it to a method returning an array of objects of a
custom class. How can this be achieved???


Bob Rock


 
Reply With Quote
 
 
 
 
Dino Chiesa [Microsoft]
Guest
Posts: n/a
 
      06-08-2004
Use [return:XmlArray] and [return:XmlArrayItem] on the return type to get it
to behave the way you want.

[WebMethod(Description="Returns an ArrayList, using XmlArrayItem to type
the members. This works. ")]
[return:System.Xml.Serialization.XmlArray(ElementNa me="MyCollection",
Namespace="http://something.org/2003/10/types")]
[return: System.Xml.Serialization.XmlArrayItem(ElementName= "Emp",
Type=typeof(CEmployee))]
[return: System.Xml.Serialization.XmlArrayItem(ElementName= "Mgr",
Type=typeof(CDeptManager))]
[return: System.Xml.Serialization.XmlArrayItem(ElementName= "Exec",
Type=typeof(CExecutive))]
[return:
System.Xml.Serialization.XmlRoot("TypedList",
Namespace="http://something.org/2003/10/types")
]
public System.Collections.ArrayList GetList_ArrayList_TypedArray()
{
.....
return whatever;
}



But, I think if you include an item in the ArrayList that is not included in
the list of [return:XmlArrayItem(...)] attributes, you'll get a runtime
error. To avoid this, you need to include a typeof(Object), which is like a
catch-all.

-Dino



"Bob Rock" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I read that XmlArrayAttribute may be applyed to "the return value that
> returns an array of complex objects" but I don't understand how.
> I'd like it to apply it to a method returning an array of objects of a
> custom class. How can this be achieved???
>
>
> Bob Rock
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
Hash#select returns an array but Hash#reject returns a hash... Srijayanth Sridhar Ruby 19 07-02-2008 12:49 PM
Problem applying return false to a div via addEventListener philjhanna Javascript 0 08-05-2005 12:57 AM
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM
Complex type as a return value Fredy Villa ASP .Net Web Services 0 11-05-2003 09:05 PM



Advertisments