Groups | Blog | Home
all groups > dotnet web services > july 2007 >

dotnet web services : Problems passing a dataset through a web service


John Wright
7/24/2007 12:11:05 PM
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_>
John Wright
7/24/2007 1:36:12 PM
[quoted text, click to view]

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
7/24/2007 1:43:19 PM

[quoted text, click to view]


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">
John Saunders [MVP]
7/24/2007 2:47:29 PM
[quoted text, click to view]

This is all that it returned? There was no SOAP envelope?
--
John Saunders [MVP]
John Wright
7/24/2007 3:54:22 PM
I figured it out. Thanks for the help.

John

John Saunders [MVP]
7/24/2007 4:01:00 PM
[quoted text, click to view]

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.
--
John Saunders [MVP]
Scott M.
7/24/2007 6:00:43 PM
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+.


[quoted text, click to view]

AddThis Social Bookmark Button