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

Discussion in 'ASP .Net Web Services' started by Bob Rock, Jun 4, 2004.

  1. Bob Rock

    Bob Rock Guest

    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
    Bob Rock, Jun 4, 2004
    #1
    1. Advertising

  2. You should look at
    http://msdn.microsoft.com/library/e...gsoapinaspnetwebserviceswebserviceclients.asp

    and
    http://msdn.microsoft.com/library/e...erializationbyxmlserializerwithattributes.asp

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

    -Dino

    "Bob Rock" <> wrote in message
    news:...
    > 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
    >
    >
    >
    Dino Chiesa [Microsoft], Jun 5, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Karl

    Name for serialized class

    Karl, Mar 13, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    407
  2. Replies:
    0
    Views:
    1,838
  3. Chandrashekar Tippur

    Java Serialized objects

    Chandrashekar Tippur, Apr 25, 2004, in forum: Java
    Replies:
    6
    Views:
    452
    Roedy Green
    Apr 26, 2004
  4. Will
    Replies:
    3
    Views:
    10,521
  5. Paul
    Replies:
    1
    Views:
    1,387
    sctosh
    Oct 21, 2009
Loading...

Share This Page