473,394 Members | 1,703 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,394 software developers and data experts.

Passing collection to web service in .NET

I wish to pass a collection object to a web service method in VB.NET, but when i try to do so i get an error message that "There was an error generating the XML", i even tried the XMLSerializer, but the same error came at different point in the program.
Can anyone tell me how to pass a collection to a web service.

User submitted from AEWNET (http://www.aewnet.com/)
Nov 21 '05 #1
1 1693
Guest,

I made this sample some days ago on a question in this newsgroup, I dont
know if it is the best method, it is about an arraylist.
\\\Create a webservice project, paste this.
<System.Web.Services.WebService(Namespace:="http ://tempuri.org/WebServiceNew/NewService")>
_
Public Class NewService
Inherits System.Web.Services.WebService
#Region " Web Services Designer Generated Code "
-----------------------------------------------------------
<WebMethod()> _
Public Function GiveArray() As String
Dim Myarray As New ArrayList
Dim myrecord As New Myfields
myrecord.fielda = "Hello"
myrecord.fieldb = "World"
Myarray.Add(myrecord)
Dim bf As New
Runtime.Serialization.Formatters.Binary.BinaryForm atter
Dim mem As New IO.MemoryStream
bf.Serialize(mem, Myarray)
Return Convert.ToBase64String(mem.ToArray())
End Function
<Serializable()> Public Class Myfields
Public fielda As String
Public fieldb As String
End Class
End Class
///
\\\Create (Add) a new winform project
'Set in that a reference to the project above
'Add a listbox
'Paste this code in
Private Sub Form1_Load(ByVal sender As Object, ByVal e _
As System.EventArgs) Handles MyBase.Load
Dim myservice As New localhost.NewService
Dim bf As New
Runtime.Serialization.Formatters.Binary.BinaryForm atter
Dim a As String = myservice.GiveArray
Dim mem As New
IO.MemoryStream(Convert.FromBase64String(myservice .GiveArray))
Dim myarraylist As ArrayList = _
DirectCast(bf.Deserialize(mem), ArrayList)
ListBox1.Items.Add(DirectCast(myarraylist(0), _
WebServiceNew.NewService.Myfields).fielda)
ListBox1.Items.Add(DirectCast(myarraylist(0), _
WebServiceNew.NewService.Myfields).fieldb)
End Sub
///

I hope this helps a little bit?

Cor

"Guest" <Guest@aew_nospam.com>

....
I wish to pass a collection object to a web service method in VB.NET, but
when i try to do so i get an error message that "There was an error
generating the XML", i even tried the XMLSerializer, but the same error
came at different point in the program.
Can anyone tell me how to pass a collection to a web service.

User submitted from AEWNET (http://www.aewnet.com/)

Nov 21 '05 #2

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

Similar topics

5
by: John Dewbert | last post by:
*** post for FREE via your newsreader at post.newsfeed.com *** Hello, I have trouble passing a folder object (from a FileSystemObject) to a sub procedure. Consider the following code: ...
1
by: vbvjain | last post by:
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...
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
2
by: Jacques Wentworth | last post by:
Hi I'm trying to pass a collection from a .NET DLL to a VB6 app. I get a error 13 (type mismatch) when I do so. I passed back a boolean variable without any problems, but when I try the...
3
by: GBR | last post by:
I have a collection object inherited from collection base that is used to carry my object entities from server to client through a web service. I want to add a dataset to this collection object and...
3
by: Malcolm | last post by:
Hi. I am attempting something new in my coding and need some direction. I have a web service that I am attempting to return a custom colleciton of custom objects of a single type. When I call...
9
by: Greger | last post by:
Hi, I am building an architecture that passes my custom objects to and from webservices. (Our internal architecture requires me to use webservices to any suggestion to use other remoting...
6
by: nickname | last post by:
I want to pass some xml to a web service method, the xml will confirm to a defined schema. Lets say the schema is defined as: <xs:schema attributeFormDefault="unqualified"...
2
by: =?Utf-8?B?Y3Nz?= | last post by:
I am new to ASP.net webservice and have a quesiton. Is is possible to pass custom object to a web service (using VB 2005)? My custom object will look like this Public Class Myclass Public...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.