Derived class not exposed in XML

Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default Derived class not exposed in XML

    Say I have a class inherited from ArrayList called MyCollection. I have a
    WebMethod that returns a MyCollection. But when I reference the service,
    the WSDL indicates that the WebMethod returns an Object array (Object()).
    When I try to assign the result to a MyCollection in my consumer, I'm told
    that the 1-dimensional Object array cannot be converted to that type. Why
    doesn't my service expose the class I've created if it's inherited from
    ArrayList?

    --
    Jeff S.


    Jeff Stewart Guest

  2. Similar Questions and Discussions

    1. Passing a derived class to a WebMethod
      I am writing a client that consumes a web service and extends the functionality of one of the web service's classes. The definition is something...
    2. #26325 [Opn]: At least a notice when accessing private members in a derived class?
      ID: 26325 User updated by: drm at melp dot nl Reported By: drm at melp dot nl Status: Open Bug Type: ...
    3. #26325 [NEW]: At least a notice when accessing private members in a derived class?
      From: drm at melp dot nl Operating system: Windows XP PHP version: 5.0.0b2 (beta2) PHP Bug Type: Feature/Change Request Bug...
    4. WS Serialization of ArrayList derived Class
      Hi Steve, You may refer to this article to see if it will help: Controlling XML Serialization Using Attributes...
    5. Access DataGrid declared in derived class from base class??
      Hi! I have a base class called ListBase.vb, from which I derive EmplList.ascx.vb. In EmplList.ascx.vb I declared a...
  3. #2

    Default Re: Derived class not exposed in XML

    I'd suggest using arrays, not ArrayList or any such derived class. ArrayList
    is a class that has semantics in the CLR, not in web services. This is almost
    analgous to returning a SqlDataReader as a return value from a web method.
    How can a java client make any sense of a SqlDataReader? Anyway, the point
    is that you shouldn't bleed out .NET native types from your web method APIs
    and instead create and use types that map well onto XML, XSD, SOAP and WSDL.

    -Brock
    DevelopMentor
    [url]http://staff.develop.com/ballen[/url]


    > Say I have a class inherited from ArrayList called MyCollection. I
    > have a WebMethod that returns a MyCollection. But when I reference
    > the service, the WSDL indicates that the WebMethod returns an Object
    > array (Object()). When I try to assign the result to a MyCollection in
    > my consumer, I'm told that the 1-dimensional Object array cannot be
    > converted to that type. Why doesn't my service expose the class I've
    > created if it's inherited from ArrayList?
    >
    > --
    > Jeff S.


    Brock Allen Guest

  4. #3

    Default Re: Derived class not exposed in XML

    Always start with XSD in mind when writing a web services, stay
    relatively simple. don't get too fancy with .Net objects. If you need to
    use a kingd of array, use list or Collection this will normally create
    and Xml element with maxOccurs="unbounded", inheritance , avoid it if
    you can, other wise take a loot at XmlIncludeAttribute

    regards
    erymuzuan mustapa

    Jeff Stewart wrote:
    > Say I have a class inherited from ArrayList called MyCollection. I have a
    > WebMethod that returns a MyCollection. But when I reference the service,
    > the WSDL indicates that the WebMethod returns an Object array (Object()).
    > When I try to assign the result to a MyCollection in my consumer, I'm told
    > that the 1-dimensional Object array cannot be converted to that type. Why
    > doesn't my service expose the class I've created if it's inherited from
    > ArrayList?
    >
    > --
    > Jeff S.
    >
    >
    erymuzuan Guest

  5. #4

    Default Re: Derived class not exposed in XML

    Philosophical differences and my opinion on Java aside, I'm very new to web
    services. < 1 week and I'm supposed to be writing a service and a consumer.
    Where does someone like me go to learn these kinds of gotchas?

    --
    Jeff S.


    "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
    news:342226632480565288726400@msnews.microsoft.com ...
    > I'd suggest using arrays, not ArrayList or any such derived class.
    > ArrayList is a class that has semantics in the CLR, not in web services.
    > This is almost analgous to returning a SqlDataReader as a return value
    > from a web method. How can a java client make any sense of a
    > SqlDataReader? Anyway, the point is that you shouldn't bleed out .NET
    > native types from your web method APIs and instead create and use types
    > that map well onto XML, XSD, SOAP and WSDL.
    >
    > -Brock
    > DevelopMentor
    > [url]http://staff.develop.com/ballen[/url]
    >
    >
    >
    >> Say I have a class inherited from ArrayList called MyCollection. I
    >> have a WebMethod that returns a MyCollection. But when I reference
    >> the service, the WSDL indicates that the WebMethod returns an Object
    >> array (Object()). When I try to assign the result to a MyCollection in
    >> my consumer, I'm told that the 1-dimensional Object array cannot be
    >> converted to that type. Why doesn't my service expose the class I've
    >> created if it's inherited from ArrayList?
    >>
    >> --
    >> Jeff S.
    >
    >
    >

    Jeff Stewart Guest

  6. #5

    Default Re: Derived class not exposed in XML

    Hmm, well, that's a tough one. Personally, I sat in on a DevelopMentor course
    on web services to get started and that's what opened by eyes. (Just in the
    interest of full disclosure, I also work/teach for DevelopMentor -- just
    to let you know :). But once I started actually doing integrations and writing
    a ton of code then I saw these problems and how the framework and VS.NET
    can hide the real issues from you. I don't have any good book recommendations
    for web services; Sorry.

    -Brock
    DevelopMentor
    [url]http://staff.develop.com/ballen[/url]

    > Philosophical differences and my opinion on Java aside, I'm very new
    > to web services. < 1 week and I'm supposed to be writing a service
    > and a consumer. Where does someone like me go to learn these kinds of
    > gotchas?
    >
    > --
    > Jeff S.
    > "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
    > news:342226632480565288726400@msnews.microsoft.com ...
    >
    >> I'd suggest using arrays, not ArrayList or any such derived class.
    >> ArrayList is a class that has semantics in the CLR, not in web
    >> services. This is almost analgous to returning a SqlDataReader as a
    >> return value from a web method. How can a java client make any sense
    >> of a SqlDataReader? Anyway, the point is that you shouldn't bleed out
    >> .NET native types from your web method APIs and instead create and
    >> use types that map well onto XML, XSD, SOAP and WSDL.
    >>
    >> -Brock
    >> DevelopMentor
    >> [url]http://staff.develop.com/ballen[/url]
    >>> Say I have a class inherited from ArrayList called MyCollection. I
    >>> have a WebMethod that returns a MyCollection. But when I reference
    >>> the service, the WSDL indicates that the WebMethod returns an Object
    >>> array (Object()). When I try to assign the result to a MyCollection
    >>> in my consumer, I'm told that the 1-dimensional Object array cannot
    >>> be converted to that type. Why doesn't my service expose the class
    >>> I've created if it's inherited from ArrayList?
    >>>
    >>> --
    >>> Jeff S.


    Brock Allen Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139