473,803 Members | 3,534 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to pass a typed dataset to a web service

I'm having a type mismatch problem when trying to pass a typed dataset to a
web service.

My code is:

CLIENT CODE

I have a dataset schema file called MainData.xsd containing a table called
mytable

'create and fill typed dataset
Dim dsMain As New MainData
Dim con As New SqlConnection(" myconnectionstr ing")
Dim da As New SqlDataAdapter( "select * .....", con)
da.Fill(dsMain. mytable)

'pass typed dataset to web service
Dim ws As New localhost.DataT ransfer
ws.PassData(dsM ain)

WEB SERVICE CODE

The web service also has an identical local file containing the data schema
called MainData.xsd

<WebMethod()> Public function PassData(Value as MainData)
....
End Function
Unfortunately I get an error when I hover over the PassData method that says
'Value of Type MainData cannot be converted to localhost.MainD ata'.

It is obviously treating the two data types as being different.

If I change the parameter type of the PassData function to type DataSet then
the function can be called OK, but then I lose the type information.

Any ideas anybody?

Thanks

Justin Crossley
Nov 21 '05 #1
1 4488
Justin Crossley wrote:
I'm having a type mismatch problem when trying to pass a typed dataset
to a web service.

... code snipped for brevity ...

Unfortunately I get an error when I hover over the PassData method
that says 'Value of Type MainData cannot be converted to
localhost.MainD ata'.

It is obviously treating the two data types as being different.
It's because they are two different data types as far as .NET knows. Even though the MainData you have generated on the client is logically the same because it was generated from the same XSD, it's not the same .NET type. So you have to use the MainData class generated by the web reference.
If I change the parameter type of the PassData function to type
DataSet then the function can be called OK, but then I lose the type
information.


Yeah, you shouldn't have to go this route though. It's less type specific and what you're doing is a perfectly viable solution. I think you're just getting confused by .NET typing vs. XSD typing.

HTH,
Drew
Nov 21 '05 #2

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

Similar topics

0
1422
by: Bj?rn Mor?n | last post by:
I am consuming a web service that returns arrays of classes which can contain other classes (a hierarchy of data). Is there a simple way to move the data into a typed DataSet without writing too much additional code? Observe that this web service does not return a DataSet explicitly, but I still want to handle the data as a DataSet at the consumer end. I havn't found any source of information on how SoapHttpClientProtocol.Invoke works...
1
2183
by: HardBap | last post by:
I've created a strongly typed DataSet (Customers.xsd) using the xsd.exe tool. I want to be able to access fields using ds.Customer.CompanyName. The problem is when I return this DataSet from a Web Service it adds another Table to the DataSet that contains the data. I have to access the data using ds.Tables.Rows.ToString(). This defeats the whole purpose of using a strongly typed DataSet. Thanks in advance for the help.
12
5317
by: Whoever | last post by:
Hi, I'm trying to return an XmlDocument or XmlNode converted from a typed dataset. public XmlNode whatever() { MyTypedDataSet ds = new MyTypedDataSet(); return new XmlDataDocument(ds); }
2
5675
by: Anil Pundhir | last post by:
What is the best way to pass data to a web service. The client(to send data) has .net environment and also the server on which the web service is hosted also has the .net environment. Should I send dataset or an xml which will be created at the client and parsed at the server, in the web service. Which will have a better performance. Thanks,
1
2423
by: Steve | last post by:
I have a windows CE application, talking to a C# WebService. In the WebService project I have created a dataset (dsJobList), and there is a web method in there which returns a fully loaded dsJobList dataset to the client, which in this case is a windows CE device. In the code for my application on the WinCE device, I have added a Web Reference to this WebService. Once I have added it I can see the .disco, the ..wsdl and a dsJobList.xsd...
2
1428
by: Deecrypt | last post by:
Hi, I'm a newbie to the Web Services topic. I have an ASP.NET website and am trying to send a Dataset from it to a WebService which should insert all the data from this DataSet to an Access database. Also I'm working with untyped datasets. I have read some topics in this newsgroup. One suggested to convert the DataSet to a string using ReadXML, send the string to the WebService, create a new Dataset and read the string back into the...
3
2503
by: Mike | last post by:
Hi, I'm delevloping a webservice that returns typed datasets with visual studio 2005. The problem is, that the typed data set in the client app is not the same as in the webservice. If I change the property 'NullValue' of the row to (empty) the dataset on the client does still throw an exception. I added a column to see if the project updates the reference.cs - and it does! This is the generated code from the original dataset:
12
3606
by: BillE | last post by:
I'm trying to decide if it is better to use typed datasets or business objects, so I would appreciate any thoughts from someone with more experience. When I use a business object to populate a gridview, for example, I loop through a datareader, populating an array list with instances of a custom class in the middle tier, and then send the array list up to the presentation layer and bind the gridview to it. If I use a typed dataset, I...
7
1743
by: =?Utf-8?B?TWF4R3J1dmVu?= | last post by:
I have a DLL that implements the Business and Data Layers for a number of different websites. That DLL uses a Strongly Typed DataSet to interface to the Data Source which is SQL Server. There is a connection string in the DLL that is causes me grief. It points at a particular instance of database. I hae to recompile the DLL for each WebSite. How can I re-use that DLL on different websites and have it point to different instances of...
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10295
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9125
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7604
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5633
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.