I thought I heard that v2 would allow a WebService to return a DataTable.
I've tried this but it doesn't seem to work, the WebService compiles but I
can't hook a client up to the method, so I have resorted back to creating a
DataSet just to transport a stupid DataTable which seems like such a waste
of code, execution time, and network bandwidth.
Am I missing something???
Thanks,
Tony
Josh Twist - 11 Feb 2006 16:22 GMT
Hi Tony,
Sorry I'm not answering your question here but you may be interested in
this. I tend to point most people at thsi who ask about returning
DataSets and DataTables - it maybe worth a rethink :)
http://www.hanselman.com/blog/ReturningDataSetsFromWebServicesIsTheSpawnOfSatanA
ndRepresentsAllThatIsTrulyEvilInTheWorld.aspx
Josh
http://www.thejoyofcode.com/
Tony - 11 Feb 2006 21:18 GMT
Yes, but that is not of much help since it just states you shouldn't but
doesn't provide a better alternative.
I'm open to suggestions of a better workable solution.
Tony
> Hi Tony,
>
[quoted text clipped - 6 lines]
> Josh
> http://www.thejoyofcode.com/
Josh Twist - 12 Feb 2006 10:02 GMT
The better alternative is to return 'real' objects. For example, if
your WebMethod is called GetApple, then your web service should return
'Apples'. That is a class Apple with the appropriate properties rather
than returning a DataSet/Table that contains columns with properties of
Apples. It's what web services are all about.
public class Apples
{
public string Type;
public int Weight;
public string Color;
}
Anyway, good luck however you decide to proceed!
Josh
http://www.thejoyofcode.com/