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 / August 2007

Tip: Looking for answers? Try searching our database.

Web Method, datatable, but send as standard types, string array

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Sitka - 24 Aug 2007 12:35 GMT
Hi,

I'm building a simple "look up" web method that would return
a table with 9 columns and a dynamic number of rows,
then I find out datatables cannot be serialized.
Not a big deal the .Net 1.1 client works with dataset.
But it got me thinking that I might as well deliver this in
a neutral format, since it's such a terribly simple return set I figured
use standard types and that would mean a 2 dimensional
string array. (rather than a Custom type such as Array of objects)

How to do this?

Signature

"it's definitely useless and maybe harmful".

John Saunders [MVP] - 24 Aug 2007 18:33 GMT
> Hi,
>
[quoted text clipped - 8 lines]
>
> How to do this?

Just return an array of a struct that has all of your 9 columns. That is
perfectly platform-neutral.
Signature

John Saunders [MVP]

John Sitka - 27 Aug 2007 13:02 GMT
Thanks
>That is perfectly platform-neutral.
I've read some of your critique about the ultimate goal of a service
Agnostic and durable, and the "training wheels" of VS.NET.
Would you have a wdsl signature of such an struct array,
or point me to a web service that does.

>> Hi,
>>
[quoted text clipped - 10 lines]
>
> Just return an array of a struct that has all of your 9 columns. That is perfectly platform-neutral.
John Saunders [MVP] - 29 Aug 2007 12:22 GMT
> Thanks
>>That is perfectly platform-neutral.
> I've read some of your critique about the ultimate goal of a service
> Agnostic and durable, and the "training wheels" of VS.NET.
> Would you have a wdsl signature of such an struct array,
> or point me to a web service that does.

This is simpler than it sounds. You should aim to return what is known as a
Data Transfer Object (DTO). This sort of object is meant to do nothing more
than transfer data from one layer to another. It is not meant to have any
behavior associated with it at all.

To give a simple example of the sort of object I mean:

public struct Order {
   public int ID;
   public int CustomerID;
   public DateTime OrderDate;
   public OrderLineItem[] LineItems;
}

public struct OrderLineItem {
   public int ID;
   public int Quantity;
   public float SalePrice;
   public Product Item;
}

public struct Product {
   public int ID;
   public string Name;
   public float StandardPrice;
   // etc.
}

[WebMethod]
public Order[] GetOrdersByCustomerID(int id)
{
   ...
}

This is a set of primitive types, and arrays and structs of primitive types,
etc. This should all map nicely and by default to and from WSDL and XSD.
Messages of this nature should be useable by any platform.
Signature

John Saunders [MVP]

John Sitka - 29 Aug 2007 13:41 GMT
Thanks,
That's what I ended up with. I realize now that in fact I didn't
want a wsdl, I just wanted the most basic of
returned XML pattern which I now understand from your
example would be ArrayofOrder.

a very simple complex type made up of  Orders

That leads me to two more questions.
How would this be delivered "as messaging". I've heard mention of this.
How would I encrypt this returned DTO.

>> Thanks
>>>That is perfectly platform-neutral.
[quoted text clipped - 38 lines]
> This is a set of primitive types, and arrays and structs of primitive types, etc. This should all map nicely and by default to and
> from WSDL and XSD. Messages of this nature should be useable by any platform.

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.