Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > WebService changed the name of my class

Reply
Thread Tools

WebService changed the name of my class

 
 
DAXU@HOTMAIL.COM
Guest
Posts: n/a
 
      10-30-2007
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?

 
Reply With Quote
 
 
 
 
John Saunders [MVP]
Guest
Posts: n/a
 
      11-03-2007
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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


 
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
changed state to up changed state to down FastEthernet LINEPROTO-5-UPDOWN surrealarmada@gmail.com Cisco 3 03-07-2007 06:06 PM
scroll position is changed when style is changed? mxbrunet Javascript 1 11-03-2006 03:40 AM
print("my name is {name}, and {age}-year old {gender}", name, age, gender); =?iso-8859-1?B?bW9vcJk=?= Java 7 01-02-2006 04:39 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
xmlDocument.Save "&#10;" getting changed changed to "&amp;#10" st@jpa.co.jp ASP .Net 1 10-11-2005 01:30 PM



Advertisments