By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,290 Members | 1,631 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,290 IT Pros & Developers. It's quick & easy.

passing collection object to web service in .NET

P: n/a

I am developing an applocation which reads mails in outlook inbo
alongwith attachments and all these informmation is stored in
collection which i need to pass it to a web service, which will perfor
certain operations on that collection and then return that modifie
collection to the client.
but when i am trying to pass a simple collection of strings to my we
service it gives me an error "You must implement Add(System.Object) a
it inherits from IColletion".
Can someone tell me the exact way as to how i can pass collection t
and from a web service in VB.NET

Thanks in advanc
-
vbvjai
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
-----------------------------------------------------------------------

Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I prefer using arrays and its collection-like counterpart, the
arraylist. When using an arraylist, you have the add and remove and
removeat methods, but the key for transferring between two objects is
the .ToArray and the .AddRange methods. The former converts the
arraylist into a literal array of objects. You can do it with Option
strict on too, but it's a bit more verbose:

dim x as dtoObject ' For illustration only
dim al as arraylist
dim obj as new webservice

obj.callingMethod(ctype(al.toarray(gettype(dtoObje ct)),dtoObject())

So what you're saying is convert the arraylist to array of type
dtoObject, but ToArray returns an object (subtype dtoObject()), so you
have to strong type it back to dtoObject()

Then when you receive it as an input parameter, its as simple as

public sub InMethod(dto() as dtoObject)
al.addrange(dto)
end sub

Hope that helps. It might not be the answer you wanted, but it is a
very easy technique that you should try. If you have a specific need to
use a Collection type, let me know and I'll clarify my answer.

vbvjain <vb************@mail.codecomments.com> wrote in
news:vb************@mail.codecomments.com:

I am developing an applocation which reads mails in outlook inbox
alongwith attachments and all these informmation is stored in a
collection which i need to pass it to a web service, which will
perform certain operations on that collection and then return that
modified collection to the client.
but when i am trying to pass a simple collection of strings to my web
service it gives me an error "You must implement Add(System.Object) as
it inherits from IColletion".
Can someone tell me the exact way as to how i can pass collection to
and from a web service in VB.NET

Thanks in advance

--
vbvjain
-----------------------------------------------------------------------
- Posted via http://www.codecomments.com
-----------------------------------------------------------------------
-


Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.