Re: Returning typed DataRow from WebMethod



"BeanDog" <BeanDog@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:4B3F68DF-0B67-4540-9230-A61AE42FBD07@xxxxxxxxxxxxxxxx
The title pretty much says it. I'm using the tutorial on MSDN for creating a
3-tiered distributed application
(http://msdn2.microsoft.com/en-us/library/aa581776.aspx), a great tutorial by
the way.

So I've created a typed dataset from my database (a table called Function),
and written the following function:

[WebMethod]
public CodeSense.FunctionRow HelloWorld() {
CodeSenseTableAdapters.FunctionTableAdapter t = new
CodeSenseTableAdapters.FunctionTableAdapter();
CodeSense.FunctionDataTable dt = t.GetData();

return dt[0];
}

This compiles fine, but the WSDL page is a runtime error saying my
FunctionRow can't be serialized.

I'm doing investigative work to see how I would put together a distributed
3-tiered web application designed for very heavy load (several hundred web
hits per second). Basically, the conclusion I came to was that I should set
up a SQL server of some sort as the data backend, then have an ASP.NET
business layer doing all the business logic, then have the business layer
expose itself to the presentation layer through either SOAP services or .NET
remoting. The presentation layer, business layer, and database layer would
each be separately load-balanced across several production servers.

These strongly-typed TableAdapters and related classes were a huge bonus for
me, since that means we won't have to create and keep up business objects in
C# that simply mirror our database schema. And .NET's great support for SOAP
serialization would make passing these to our non-.NET presentation tier a
trivial matter.

Unfortunately, it looks like this fantastic feature (automatically-generated
strongly-typed DataRows) is going to be basically unusable since I can't pass
these objects from my business tier to my presentation tier. That is, I
can't return them through either .NET remoting or .NET WebServices.

What's the preferred method for passing strongly-typed DataRows from a
business-logic tier to a presentation tier running on a physically separate
server?

Sorry for the late reply. I only just started monitoring this newsgroup. For anyone still listening, here's my response:

1) You cannot serialize any kind of DataRow because the DataRow class does not have a public default constructor. You can, however, return a DataTable with a single row in it, or even a DataSet.
2) As soon as you start to talk about passing .NET-specific types between layers, you are no longer talking about using Web Services. The Web Services platform is meant to be platform-neutral. Any platform dependencies that sneak through are the result of magic or bugs, and should not be relied upon. If you need to communicate between tiers of the same application, then you should use .NET Remoting instead. It can be configured to use either SOAP or binary encoding.


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

.



Relevant Pages

  • Re: Application logic and Business logic
    ... you need to handle PCs, windowing interfaces, new ATM networks, POS networks, ... Would you rather your business logic be wrapped-up inside the dumb-terminal ... business layer to have hardwired itself to a specific table layout is nearly ... Better to treat the database as a huge object that hides its data (table, ...
    (comp.object)
  • Re: N Tier Architecture ?
    ... my contribution will be to explain the underlying principles which guide ... layer of an N-Tier app, for example, should have an API that is not tied to ... the business layer of an N-Tier application should be designed to ... the presentation tier encapsulates only user interface logic. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: "Business Objects" and the DAL
    ... layer talks to the layer next to it. ... business entity returned that up to the UI for binding to a grid. ... If a database table column names ... Each could be considered a "pattern", ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Newbie object design questions
    ... generate typed datasets from stored procedures, ... When you come along to change things in the database, ... > database in the same way that the business thinks of them. ... > Mediating between these two points of view is what a business layer is ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Am i thinking correctly?? business objects inserting to database
    ... We are building the new application using a 3 tier ... What I generally do is create a class for each business object. ... classes themselves know nothing of the database. ... Next I create Data Access layer that knows how to take a Value object ...
    (microsoft.public.dotnet.general)

Loading