Re: WebService changed the name of my class



<DAXU@xxxxxxxxxxx> wrote in message
news:1193749903.003645.195390@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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


.



Relevant Pages

  • Re: SOAP project
    ... | The interop problems I've seen are between .NET and AXIS, ... | There's another Web Service written in perl. ... there is no WSDL for that. ...
    (microsoft.public.dotnet.languages.csharp)
  • How to extend WSDL to return (not used) Schema elements?
    ... on an element in some XML Schema. ... Reference" I'm referring to a web service having a method looking like: ... I would like to somehow add the element "webSite" into ... If I could have this returned in my WSDL I would then be able to use the ...
    (microsoft.public.dotnet.framework.webservices)
  • Problems with XML, XSD, Web, Services & InfoPath
    ... I have created a web service for retrieving customer data and for updating ... I have created a XML schema. ... I decided to use InfoPath for testing things out. ... The data table on SQL Server 2000 allows nulls. ...
    (microsoft.public.dotnet.xml)
  • Problems with XML, XSD, Web, Services & InfoPath
    ... I have created a web service for retrieving customer data and for updating ... I have created a XML schema. ... I decided to use InfoPath for testing things out. ... The data table on SQL Server 2000 allows nulls. ...
    (microsoft.public.dotnet.framework.adonet)
  • creating web services dynamically
    ... I can create a WSDL file based on the XML schema for each web service I create. ... What I want to do is create a single implementation for all of my dynamically created web services that will interrogate an input XMLDocument, and return the appropriate result based on the identity of the invoked operation as another XMLDocument. ...
    (microsoft.public.dotnet.framework.webservices)

Quantcast