WebService changed the name of my class

Discussion in 'ASP .Net Web Services' started by DAXU@HOTMAIL.COM, Oct 30, 2007.

  1. Guest

    Hi,
    I am new to web service and I have a class called Pair like this:
    [Serializable]
    public class Pair<A, B>
    {
    public Pair()
    {
    First = default(A);
    Second = default(B);
    }
    ......
    }

    I created a web method to return a Pair class (e.g. Pair<int,
    DataSet>), and then have a web page to consume the returned Pair
    class. However, from metadata the return of the web method become:
    public class PairOfInt32DataSet
    {
    public PairOfInt32DataSet();

    public int First { get; set; }
    public DataSet Second { get; set; }
    }

    Can someone tell me why?
     
    , Oct 30, 2007
    #1
    1. Advertisements

  2. <> wrote in message
    news:...
    > Hi,
    > I am new to web service and I have a class called Pair like this:
    > [Serializable]
    > public class Pair<A, B>
    > {
    > public Pair()
    > {
    > First = default(A);
    > Second = default(B);
    > }
    > ......
    > }
    >
    > I created a web method to return a Pair class (e.g. Pair<int,
    > DataSet>), and then have a web page to consume the returned Pair
    > class. However, from metadata the return of the web method become:
    > public class PairOfInt32DataSet
    > {
    > public PairOfInt32DataSet();
    >
    > public int First { get; set; }
    > public DataSet Second { get; set; }
    > }
    >
    > Can someone tell me why?


    Web services don't process objects - they process XML. The service is
    described by a WSDL, and the WSDL uses XML Schema to describe the XML to be
    sent and received.

    XML Schema has no way to describe generics.

    When you "have a web service that returns a Pair<int,DataSet>", .NET will
    produce a WSDL that includes an XML Schema that describes an XML complexType
    named PairOfInt32DataSet. When you create proxy classes for your client
    using Add Web Reference, .NET will create the proxy class PairOfIntDataSet,
    as you have seen.

    If you were consuming this web service from a platform other than .NET,
    things would be even worse, as the .NET class "DataSet" does not exist on
    platforms other than .NET.

    So, two things:

    1) What you see is the expected behavior. Platform-specific types will not
    translate across web services
    2) It is a bad idea to pass DataSet objects or other platform-specific
    types, as they will not translate across platforms.
    --
    --------------------------------------------------------------------------------
    John Saunders | MVP - Windows Server System - Connected System Developer
     
    John Saunders [MVP], Nov 3, 2007
    #2
    1. Advertisements

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. Replies:
    1
    Views:
    926
    Rosanne
    Oct 11, 2005
  2. E11
    Replies:
    1
    Views:
    5,732
    Thomas Weidenfeller
    Oct 12, 2005
  3. =?iso-8859-1?B?bW9vcJk=?=
    Replies:
    7
    Views:
    1,133
    Roedy Green
    Jan 2, 2006
  4. ding feng
    Replies:
    2
    Views:
    3,267
    ding feng
    Jun 25, 2003
  5. Bobby Chamness
    Replies:
    2
    Views:
    2,623
    Joe Smith
    Apr 22, 2007
  6. Jack-2
    Replies:
    3
    Views:
    589
    Jack-2
    Dec 24, 2003
  7. Java  script  Dude

    IE name="name" & form.name property bug

    Java script Dude, Jun 29, 2004, in forum: Javascript
    Replies:
    5
    Views:
    501
    Java script Dude
    Jun 30, 2004
  8. mxbrunet
    Replies:
    1
    Views:
    405
Loading...