Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / November 2007

Tip: Looking for answers? Try searching our database.

WebService changed the name of my class

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DAXU@HOTMAIL.COM - 30 Oct 2007 14:11 GMT
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?
John Saunders [MVP] - 03 Nov 2007 21:37 GMT
> Hi,
> I am new to web service and I have a class called Pair like this:
[quoted text clipped - 21 lines]
>
> 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.
Signature

--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.