Problem with return type in webservice

P

Peter Longstaff

Hi All,

I am having trouble with my first effort at developing a web service.

I have a methods, outlined below which should return a DataTable.

[WebMethod(Description = "Gets details for contact for the ID provided")]
public DataTable GetContactsforCompany(string sID)
{
if (sID == string.Empty)
return new DataTable();

return getContactsForCompany(sID);

}


Unfortunately when I call the methood in an application the return type
is: GetContractsForCompanyResponseGetContactsForCompanyResult

and the only properties avaialable are "Any"

Can anybody tell me why?

TIA
Peter Longstaff
 
G

Guest

Try adding the DataTable to a DataSet in the WebMethod and return a DataSet.
At the client, you can get your DataTable back out with
MyDataSet.Tables[0]

Peter
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Peter said:
I am having trouble with my first effort at developing a web service.

I have a methods, outlined below which should return a DataTable.

[WebMethod(Description = "Gets details for contact for the ID provided")]
public DataTable GetContactsforCompany(string sID)
{
if (sID == string.Empty)
return new DataTable();

return getContactsForCompany(sID);

}

Why pay the huge overhead of converting to a technology
neutral format like SOAP and then return a data type that
is .NET specific ?

I would either use a binary protocol like .NET Remoting
with the DataTable/DataSet or use SOAP/HTTP with a
portable data type (like array of object with properties).

Arne
 
G

Guest

Arne,
You are way over the OP's head - this is his first webservice and he *wants*
to return a Datatable (actually he *would* need a dataset containing a
datatable).

I agree about returning provider-neutral types wholeheartedly. However, if
you are starting out with a webservice to begin with, this idea of a "huge
overhead" becomes a moot issue, IMHO.
Peter


--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




Arne Vajhøj said:
Peter said:
I am having trouble with my first effort at developing a web service.

I have a methods, outlined below which should return a DataTable.

[WebMethod(Description = "Gets details for contact for the ID provided")]
public DataTable GetContactsforCompany(string sID)
{
if (sID == string.Empty)
return new DataTable();

return getContactsForCompany(sID);

}

Why pay the huge overhead of converting to a technology
neutral format like SOAP and then return a data type that
is .NET specific ?

I would either use a binary protocol like .NET Remoting
with the DataTable/DataSet or use SOAP/HTTP with a
portable data type (like array of object with properties).

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top