473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

returning generics

Hi
Can generics be returned by the WebMethod?
Iam thinking about <List>.
Anyways where can i find list of all values that can be actually passed o
returned within webservice connection?
Thanks
PK

Apr 29 '07 #1
2 2343
Yes, I read somewhere in the forums it is possible. But I'm trying to find
a good example to use myself. I'm considering a collection, because it's a
known type and structured, but I still can't find a working example
anywhere. I wish that people who post solutions would actually give us good
examples instead of one liners that go nowhere. It's interesting that I
don't have such problems in the VBA forums. If I run into anything, I will
let you know.

John

"piter" <pi*************@gmail.comwrote in message
news:39***************************@news.chello.pl. ..
Hi
Can generics be returned by the WebMethod?
Iam thinking about <List>.
Anyways where can i find list of all values that can be actually passed o
returned within webservice connection?
Thanks
PK

May 29 '07 #2
"John Cosmas" <jo********@charter.netwrote in message
news:gP**************@newsfe04.lga...
Yes, I read somewhere in the forums it is possible. But I'm trying to
find a good example to use myself. I'm considering a collection, because
it's a known type and structured, but I still can't find a working example
anywhere. I wish that people who post solutions would actually give us
good examples instead of one liners that go nowhere. It's interesting
that I don't have such problems in the VBA forums. If I run into
anything, I will let you know.
John et. al.,

I'm sorry I haven't been able to provide better or more detailed answers.
I've got a release due Monday and have little time left over for helping
out.

Briefly, though, I want to caution everyone about using platform-specific
types in web services, either as parameters or return values. The Web
Services infrastructure was meant to be platform-neutral. In this regard,
consider that many platforms have no concept of generics.

Further, consider that a generic method does not represent a single method.
Rather, it represents a family of methods. This would make it even more
complicated to implement in a cross-platform manner.

That said, I believe you can get a web service to return a generic
instantiation:

[WebMethod]
public MyGeneric<int, stringMyGenericMethod(int x, string y);

I believe I've seen a generated WSDL for such a method containing a
manufactured name containing "int" and "string". Something like
"MyGenericOfIntAndString".

Much the same comment applies to things like List<T>. In this case, you
might be able to use XML Serialization attributes to turn this into an array
of T.

I would recommend that any developers new to Web Services should start off
by programming against the "least-common denominator" model that will work
on any platform. For instance, if you want to use List<Tinside of your web
service, go ahead - but you'll be better off (*) working with an array of T
(for a specific T). This will correspond better to what the infrastructure
is geared to send and receive.
--
John Saunders [MVP]

(*) After gaining experience with the basics of the infrastructure, go ahead
and challenge it. You will by then understand how things work "under the
covers", and you'll be in a better position to learn how to make Web
Services "do tricks".
May 29 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: Bernardo Heynemann | last post by:
How can I use Generics? How can I use C# 2.0? I already have VS.NET 2003 Enterprise Edition and still can´t use generics... I´m trying to make a generic collection myCollection<vartype> and...
23
by: Luc Vaillant | last post by:
I need to initialise a typed parameter depending of its type in a generic class. I have tried to use the C++ template form as follow, but it doesn't work. It seems to be a limitation of generics...
12
by: Michael S | last post by:
Why do people spend so much time writing complex generic types? for fun? to learn? for use? I think of generics like I do about operator overloading. Great to have as a language-feature, as...
9
by: sloan | last post by:
I'm not the sharpest knife in the drawer, but not a dummy either. I'm looking for a good book which goes over Generics in great detail. and to have as a reference book on my shelf. Personal...
1
by: Vladimir Shiryaev | last post by:
Hello! Exception handling in generics seems to be a bit inconsistent to me. Imagine, I have "MyOwnException" class derived from "ApplicationException". I also have two classes...
7
by: SpotNet | last post by:
Hello NewsGroup, Reading up on Generics in the .NET Framework 2.0 using C# 2005 (SP1), I have a question on the application of Generics. Knowingly, Generic classes are contained in the...
5
by: admin | last post by:
I have a class that has a function that should query a database and return a list of usernames as well as their id. What type should I use as a return type, that can hold data such as: user1, 1...
13
by: rkausch | last post by:
Hello everyone, I'm writing because I'm frustrated with the implementation of C#'s generics, and need a workaround. I come from a Java background, and am currently writing a portion of an...
0
by: jobs | last post by:
re: ObjectDataSource SelectMethod TypeName returning a Dataset? is this really a DAL? Pardon my misguided email on the subject... I'm working in asp.net 2.0 and vb.net 2005. Say I don't...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.