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.

Problems passing a dataset through a web service

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Wright - 24 Jul 2007 19:11 GMT
I have a datatable I create and fill with a simple SQL Statement.  I add the
table to a dataset and return the dataset through a webservice to the
client.  I have tested the method through the Invoke page created by Visual
Studio and it does return a dataset (I have attached a small portion of it).
But when I call the method through a web service I get the following error:

System.Web.Services.Protocols.SoapException: Server was unable to process
request. ---> System.ArgumentNullException: 'table' argument cannot be null.
Parameter name: table
  at System.Data.DataTableCollection.BaseAdd(DataTable table)
  at System.Data.DataTableCollection.Add(DataTable table)
  at Service.GetData()
  --- End of inner exception stack trace ---

Here is he code that the web service uses to get the data (with my
comments).  Any help on this would be much appreciated.

John

<WebMethod()> _

Public Function GetData() As Data.DataSet

myDAL.ProviderName = "System.Data.SqlClient"

myDAL.ConnectionString = connection string

Dim tempDT As Data.DataTable = New Data.DataTable

tempDT = myDAL.ExecuteDataTable("SELECT * FROM PRODUCT")  --> This process
goes to a class module in the code that takes the sql statment connects to
the database and returns a datatable

GetData = New Data.DataSet 'Set the DataSet

GetData.Tables.Add(tempDT) 'Add the DataTable

Return GetData 'Return it

End Function

As I said this works just fine.  Here is an example of the data it returns
(XML from the invoke).

<?xml version="1.0" encoding="utf-8" ?>
- <DataSet xmlns="http://tempuri.org/">
- <xs:schema id="NewDataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xs:element name="NewDataSet" msdata:IsDataSet="true"
msdata:UseCurrentLocale="true">
- <xs:complexType>
- <xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:element name="Table1">
- <xs:complexType>
- <xs:sequence>
 <xs:element name="Product__x0023_" msdata:ReadOnly="true"
msdata:AutoIncrement="true" type="xs:int" />
 <xs:element name="Traveler__x0023_" type="xs:int" />
 <xs:element name="Type__x0023_" type="xs:int" />
- <xs:element name="Part_Number">
- <xs:simpleType>
- <xs:restriction base="xs:string">
 <xs:maxLength value="20" />
 </xs:restriction>
 </xs:simpleType>
 </xs:element>
 <xs:element name="Date_Shipped" type="xs:dateTime" minOccurs="0" />
 <xs:element name="Operator__x0023_" type="xs:int" />
 <xs:element name="Create_Date" type="xs:dateTime" />
 <xs:element name="Shop_Order__x0023_" type="xs:int" />
 <xs:element name="Date_Closed" type="xs:dateTime" minOccurs="0" />
- <xs:element name="Ingot_Number" minOccurs="0">
- <xs:simpleType>
- <xs:restriction base="xs:string">
 <xs:maxLength value="20" />
 </xs:restriction>
 </xs:simpleType>
 </xs:element>
 <xs:element name="Status__x0023_" type="xs:int" minOccurs="0" />
- <xs:element name="Anneal_Number" minOccurs="0">
- <xs:simpleType>
- <xs:restriction base="xs:string">
 <xs:maxLength value="20" />
 </xs:restriction>
 </xs:simpleType>
 </xs:element>
- <xs:element name="MRT_Number" minOccurs="0">
- <xs:simpleType>
- <xs:restriction base="xs:string">
 <xs:maxLength value="20" />
 </xs:restriction>
 </xs:simpleType>
 </xs:element>
 <xs:element name="Double_Single_Length" type="xs:int" minOccurs="0" />
 <xs:element name="Carton__x0023_" type="xs:int" minOccurs="0" />
 <xs:element name="Weight" type="xs:int" minOccurs="0" />
 <xs:element name="Sister_Piece__x0023_" type="xs:int" minOccurs="0" />
 <xs:element name="Slab_Traveler__x0023_" type="xs:int" minOccurs="0" />
 <xs:element name="Chemistry__x0023_" type="xs:int" minOccurs="0" />
- <xs:element name="Traveler_Number" minOccurs="0">
- <xs:simpleType>
- <xs:restriction base="xs:string">
 <xs:maxLength value="15" />
 </xs:restriction>
 </xs:simpleType>
 </xs:element>
- <xs:element name="Plate_ID" minOccurs="0">
- <xs:simpleType>
- <xs:restriction base="xs:string">
 <xs:maxLength value="10" />
 </xs:restriction>
 </xs:simpleType>
 </xs:element>
 <xs:element name="FinalID" type="xs:boolean" minOccurs="0" />
 <xs:element name="Traveler_Step__x0023_" type="xs:int" minOccurs="0" />
 <xs:element name="Marked" type="xs:int" minOccurs="0" />
 </xs:sequence>
 </xs:complexType>
 </xs:element>
 </xs:choice>
 </xs:complexType>
 </xs:element>
 </xs:schema>
- <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
- <NewDataSet xmlns="">
- <Table1 diffgr:id="Table11" msdata:rowOrder="0">
 <Product__x0023_>244</Product__x0023_>
 <Traveler__x0023_>17</Traveler__x0023_>
 <Type__x0023_>1</Type__x0023_>
 <Part_Number>U06436L</Part_Number>
 <Operator__x0023_>10</Operator__x0023_>
 <Create_Date>2007-04-12T12:48:32.61-06:00</Create_Date>
 <Shop_Order__x0023_>12</Shop_Order__x0023_>
 <Ingot_Number>U06436L</Ingot_Number>
 <Status__x0023_>1</Status__x0023_>
 <Chemistry__x0023_>2</Chemistry__x0023_>
 <Traveler_Number>52896</Traveler_Number>
 <FinalID>false</FinalID>
 <Traveler_Step__x0023_>133</Traveler_Step__x0023_>
 <Marked>0</Marked>
 </Table1>
- <Table1 diffgr:id="Table12" msdata:rowOrder="1">
 <Product__x0023_>245</Product__x0023_>
 <Traveler__x0023_>18</Traveler__x0023_>
 <Type__x0023_>2</Type__x0023_>
 <Part_Number>U06436LA</Part_Number>
 <Operator__x0023_>4</Operator__x0023_>
 <Create_Date>2007-04-12T13:14:15.613-06:00</Create_Date>
 <Shop_Order__x0023_>12</Shop_Order__x0023_>
 <Ingot_Number>U06436L</Ingot_Number>
 <Status__x0023_>1</Status__x0023_>
 <Weight>2360</Weight>
 <Slab_Traveler__x0023_>89</Slab_Traveler__x0023_>
 <Chemistry__x0023_>2</Chemistry__x0023_>
 <Traveler_Number>52896A</Traveler_Number>
 <FinalID>false</FinalID>
 <Traveler_Step__x0023_>142</Traveler_Step__x0023_>
 <Marked>0</Marked>
 </Table1>
- <Table1 diffgr:id="Table13" msdata:rowOrder="2">
 <Product__x0023_>246</Product__x0023_>
 <Traveler__x0023_>18</Traveler__x0023_>
 <Type__x0023_>2</Type__x0023_>
 <Part_Number>U06436LB</Part_Number>
 <Operator__x0023_>4</Operator__x0023_>
 <Create_Date>2007-04-12T13:14:24.923-06:00</Create_Date>
 <Shop_Order__x0023_>12</Shop_Order__x0023_>
 <Ingot_Number>U06436L</Ingot_Number>
 <Status__x0023_>1</Status__x0023_>
 <Weight>2510</Weight>
 <Slab_Traveler__x0023_>90</Slab_Traveler__x0023_>
 <Chemistry__x0023_>2</Chemistry__x0023_>
 <Traveler_Number>52896B</Traveler_Number>
 <FinalID>false</FinalID>
 <Traveler_Step__x0023_>142</Traveler_Step__x0023_>
 <Marked>0</Marked>
 </Table1>
- <Table1 diffgr:id="Table14" msdata:rowOrder="3">
 <Product__x0023_>247</Product__x0023_>
 <Traveler__x0023_>18</Traveler__x0023_>
 <Type__x0023_>2</Type__x0023_>
 <Part_Number>U06436LC</Part_Number>
 <Operator__x0023_>4</Operator__x0023_>
 <Create_Date>2007-04-12T13:14:34.72-06:00</Create_Date>
 <Shop_Order__x0023_>12</Shop_Order__x0023_>
 <Ingot_Number>U06436L</Ingot_Number>
 <Status__x0023_>1</Status__x0023_>
 <Weight>2320</Weight>
 <Slab_Traveler__x0023_>91</Slab_Traveler__x0023_>
 <Chemistry__x0023_>2</Chemistry__x0023_>
 <Traveler_Number>52896C</Traveler_Number>
 <FinalID>false</FinalID>
 <Traveler_Step__x0023_>142</Traveler_Step__x0023_>
 <Marked>0</Marked>
 </Table1>
John Saunders [MVP] - 24 Jul 2007 19:47 GMT
>I have a datatable I create and fill with a simple SQL Statement.  I add
>the table to a dataset and return the dataset through a webservice to the
[quoted text clipped - 48 lines]
> xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
> - <xs:element name="NewDataSet" msdata:IsDataSet="true"

This is all that it returned? There was no SOAP envelope?
Signature

John Saunders [MVP]

John Wright - 24 Jul 2007 20:36 GMT
>>I have a datatable I create and fill with a simple SQL Statement.  I add
>>the table to a dataset and return the dataset through a webservice to the
[quoted text clipped - 50 lines]
>
> This is all that it returned? There was no SOAP envelope?

This is what was returned and displayed on the result page.  No SOAP
envelope.  I found out how to pass a DataTable as well (I assigned a table
name so it could be serialized) and it returns a similar result.  Am I
missing something?

John
John Wright - 24 Jul 2007 20:43 GMT
>>>I have a datatable I create and fill with a simple SQL Statement.  I add
>>>the table to a dataset and return the dataset through a webservice to the
[quoted text clipped - 57 lines]
>
> John

Sorry, here is the SOAP envelope.

 <?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
targetNamespace="http://tempuri.org/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <s:schema elementFormDefault="qualified"
targetNamespace="http://tempuri.org/">
- <s:element name="HelloWorld">
 <s:complexType />
 </s:element>
- <s:element name="HelloWorldResponse">
- <s:complexType>
- <s:sequence>
 <s:element minOccurs="0" maxOccurs="1" name="HelloWorldResult"
type="s:string" />
 </s:sequence>
 </s:complexType>
 </s:element>
- <s:element name="GetData">
 <s:complexType />
 </s:element>
- <s:element name="GetDataResponse">
- <s:complexType>
- <s:sequence>
- <s:element minOccurs="0" maxOccurs="1" name="GetDataResult">
- <s:complexType>
- <s:sequence>
 <s:element ref="s:schema" />
 <s:any />
 </s:sequence>
 </s:complexType>
 </s:element>
 </s:sequence>
 </s:complexType>
 </s:element>
- <s:element name="GetDataDT">
 <s:complexType />
 </s:element>
- <s:element name="GetDataDTResponse">
- <s:complexType>
- <s:sequence>
- <s:element minOccurs="0" maxOccurs="1" name="GetDataDTResult">
- <s:complexType>
- <s:sequence>
 <s:any minOccurs="0" maxOccurs="unbounded"
namespace="http://www.w3.org/2001/XMLSchema" processContents="lax" />
 <s:any minOccurs="1" namespace="urn:schemas-microsoft-com:xml-diffgram-v1"
processContents="lax" />
 </s:sequence>
 </s:complexType>
 </s:element>
 </s:sequence>
 </s:complexType>
 </s:element>
 </s:schema>
 </wsdl:types>
- <wsdl:message name="HelloWorldSoapIn">
 <wsdl:part name="parameters" element="tns:HelloWorld" />
 </wsdl:message>
- <wsdl:message name="HelloWorldSoapOut">
 <wsdl:part name="parameters" element="tns:HelloWorldResponse" />
 </wsdl:message>
- <wsdl:message name="GetDataSoapIn">
 <wsdl:part name="parameters" element="tns:GetData" />
 </wsdl:message>
- <wsdl:message name="GetDataSoapOut">
 <wsdl:part name="parameters" element="tns:GetDataResponse" />
 </wsdl:message>
- <wsdl:message name="GetDataDTSoapIn">
 <wsdl:part name="parameters" element="tns:GetDataDT" />
 </wsdl:message>
- <wsdl:message name="GetDataDTSoapOut">
 <wsdl:part name="parameters" element="tns:GetDataDTResponse" />
 </wsdl:message>
- <wsdl:portType name="ServiceSoap">
- <wsdl:operation name="HelloWorld">
 <wsdl:input message="tns:HelloWorldSoapIn" />
 <wsdl:output message="tns:HelloWorldSoapOut" />
 </wsdl:operation>
- <wsdl:operation name="GetData">
 <wsdl:input message="tns:GetDataSoapIn" />
 <wsdl:output message="tns:GetDataSoapOut" />
 </wsdl:operation>
- <wsdl:operation name="GetDataDT">
 <wsdl:input message="tns:GetDataDTSoapIn" />
 <wsdl:output message="tns:GetDataDTSoapOut" />
 </wsdl:operation>
 </wsdl:portType>
- <wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">
 <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="HelloWorld">
 <soap:operation soapAction="http://tempuri.org/HelloWorld"
style="document" />
- <wsdl:input>
 <soap:body use="literal" />
 </wsdl:input>
- <wsdl:output>
 <soap:body use="literal" />
 </wsdl:output>
 </wsdl:operation>
- <wsdl:operation name="GetData">
 <soap:operation soapAction="http://tempuri.org/GetData" style="document"
/>
- <wsdl:input>
 <soap:body use="literal" />
 </wsdl:input>
- <wsdl:output>
 <soap:body use="literal" />
 </wsdl:output>
 </wsdl:operation>
- <wsdl:operation name="GetDataDT">
 <soap:operation soapAction="http://tempuri.org/GetDataDT" style="document"
/>
- <wsdl:input>
 <soap:body use="literal" />
 </wsdl:input>
- <wsdl:output>
 <soap:body use="literal" />
 </wsdl:output>
 </wsdl:operation>
 </wsdl:binding>
- <wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
 <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="HelloWorld">
 <soap12:operation soapAction="http://tempuri.org/HelloWorld"
style="document" />
- <wsdl:input>
 <soap12:body use="literal" />
 </wsdl:input>
- <wsdl:output>
 <soap12:body use="literal" />
 </wsdl:output>
 </wsdl:operation>
- <wsdl:operation name="GetData">
 <soap12:operation soapAction="http://tempuri.org/GetData" style="document"
/>
- <wsdl:input>
 <soap12:body use="literal" />
 </wsdl:input>
- <wsdl:output>
 <soap12:body use="literal" />
 </wsdl:output>
 </wsdl:operation>
- <wsdl:operation name="GetDataDT">
 <soap12:operation soapAction="http://tempuri.org/GetDataDT"
style="document" />
- <wsdl:input>
 <soap12:body use="literal" />
 </wsdl:input>
- <wsdl:output>
 <soap12:body use="literal" />
 </wsdl:output>
 </wsdl:operation>
 </wsdl:binding>
- <wsdl:service name="Service">
- <wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">
 <soap:address location="http://localhost:60437/webserviceDT/Service.asmx"
/>
 </wsdl:port>
- <wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">
 <soap12:address
location="http://localhost:60437/webserviceDT/Service.asmx" />
 </wsdl:port>
 </wsdl:service>
 </wsdl:definitions>
John Saunders [MVP] - 24 Jul 2007 21:01 GMT
>>>>I have a datatable I create and fill with a simple SQL Statement.  I add
>>>>the table to a dataset and return the dataset through a webservice to
[quoted text clipped - 65 lines]
> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"

Well, no, this is the WSDL.

Why don't you try using soapUI, from http://www.soapui.org/ to test the
service. It does a much better job of telling you what's going on than a
browser does, and it's free.
Signature

John Saunders [MVP]

John Wright - 24 Jul 2007 22:54 GMT
I figured it out.  Thanks for the help.

John
Scott M. - 24 Jul 2007 23:00 GMT
IMHO, if you are returning a DataSet, you are missing the point of web
services entirely.  Why not return the DataSet's XML, which can then be
consumed by any web client.  If you pass a DataSet, you are limiting
yourself to a .NET consumer, in which case, you might as well just use DCOM
or COM+.

>I figured it out.  Thanks for the help.
>
> John
rcitguy - 21 Aug 2007 21:27 GMT
Hello John,
               Would you mind elaborating on how you resolved this?  I have
a similar issue.
RCITGUY
-----------------
>I figured it out.  Thanks for the help.
>
>John

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.