[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webservices

How to control the root name with which an array of a custom class objects are serialized????

Bob Rock

6/4/2004 4:42:00 PM

Hello,

is there a way of controlling the name with which an array of objects of a
custom class is serialized???

public class MyClass
{
......
}

[WebMethod]
public MyClass[] MyMethod()
{
......
......
}

When serializing an array of MyClass objects through a web method I get as
the root node something like <ArrayOfMyClass1 xmlns="...." ....>.
I'd like to be able to define myself the name of the root element. Can this
be done???

Bob Rock



1 Answer

Dino Chiesa [Microsoft]

6/5/2004 1:28:00 AM

0

You should look at
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcustomizingsoapinaspnetwebserviceswebservicec...

and
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcontrollingserializationbyxmlserializerwithattr...

I think if you apply a
[return: XmlArray("ElementName")]
attribute to the webmethod, you may get what you want.

-Dino

"Bob Rock" <nospam.yet_another_apprentice@hotmail.com> wrote in message
news:OxpUkIkSEHA.3476@tk2msftngp13.phx.gbl...
> Hello,
>
> is there a way of controlling the name with which an array of objects of a
> custom class is serialized???
>
> public class MyClass
> {
> ......
> }
>
> [WebMethod]
> public MyClass[] MyMethod()
> {
> ......
> ......
> }
>
> When serializing an array of MyClass objects through a web method I get as
> the root node something like <ArrayOfMyClass1 xmlns="...." ....>.
> I'd like to be able to define myself the name of the root element. Can
this
> be done???
>
> Bob Rock
>
>
>