Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > WebServices Return DataSet + String as Object

Reply
Thread Tools

WebServices Return DataSet + String as Object

 
 
SMG
Guest
Posts: n/a
 
      04-22-2005

Hi All,
I have a Web Service, which returns a DataSet and I am able to consume.
This is ok.

Now I want to return two things,
1. DataSet
2. String
Through one request only, I thot of using object as a return type to the
webservices but then how do I re cast it to string and dataset. Will that
work.
I tried with object array it didn't work with that, it says "implement
IConvertible"

Any Idea how do we use and consume the same.

Regards,
Shailesh Gajare


 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGF0cmljaw==?=
Guest
Posts: n/a
 
      04-22-2005
Hi SMG,

you could add another table to the DataSet, which holds the string
reference. Or you can (as you described) a object-array:

....
return (new object [] { myStringValue , myDataSet });
....

You can read it as follows:
if (myResult != null && myResult.Length == 2)
{
localDataSet = myResult [1];
localString = myResult [0];

// do something you want with the references
}

Regards
Patrick

"SMG" wrote:

>
> Hi All,
> I have a Web Service, which returns a DataSet and I am able to consume.
> This is ok.
>
> Now I want to return two things,
> 1. DataSet
> 2. String
> Through one request only, I thot of using object as a return type to the
> webservices but then how do I re cast it to string and dataset. Will that
> work.
> I tried with object array it didn't work with that, it says "implement
> IConvertible"
>
> Any Idea how do we use and consume the same.
>
> Regards,
> Shailesh Gajare
>
>
>

 
Reply With Quote
 
 
 
 
JD
Guest
Posts: n/a
 
      04-24-2005
You could always return a class. The code below shoe show the idea.

Class ReturnMe
public DS as Dataset
public Str as string
end class

class WebServiceClas()
.....
<webmethod> public function ReturnData(...) as ReturnMe
......
end class

"SMG" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

>
> Hi All,
> I have a Web Service, which returns a DataSet and I am able to
> consume.
> This is ok.
>
> Now I want to return two things,
> 1. DataSet
> 2. String
> Through one request only, I thot of using object as a return type to
> the webservices but then how do I re cast it to string and dataset.
> Will that work.
> I tried with object array it didn't work with that, it says "implement
> IConvertible"
>
> Any Idea how do we use and consume the same.
>
> Regards,
> Shailesh Gajare
>
>
>


 
Reply With Quote
 
SMG
Guest
Posts: n/a
 
      04-25-2005
Thanks JD

But for that, the end user who are using my webservices should be aware of
such classes or I need to give that class file as well along with the
description of the web service.

Is it the right way to do it?
what does Best Practices suggest?

Regards,
Shailesh



"JD" <(E-Mail Removed)> wrote in message
news:Xns9641EBEAE58E9invalidemailcom@199.45.49.11. ..
You could always return a class. The code below shoe show the idea.

Class ReturnMe
public DS as Dataset
public Str as string
end class

class WebServiceClas()
.....
<webmethod> public function ReturnData(...) as ReturnMe
......
end class

"SMG" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

>
> Hi All,
> I have a Web Service, which returns a DataSet and I am able to
> consume.
> This is ok.
>
> Now I want to return two things,
> 1. DataSet
> 2. String
> Through one request only, I thot of using object as a return type to
> the webservices but then how do I re cast it to string and dataset.
> Will that work.
> I tried with object array it didn't work with that, it says "implement
> IConvertible"
>
> Any Idea how do we use and consume the same.
>
> Regards,
> Shailesh Gajare
>
>
>



 
Reply With Quote
 
JD
Guest
Posts: n/a
 
      04-26-2005
The class will be exposed to the users, once you have your webmethod
return the class back.
Users code:
(make sure once you compile you webservice to update your web ref)
Dim a as new WebServ.WebServiceClas

'This will be automatically created in the WSDL
Dim b as ReturnMe

b = a.ReturnData()
'Do whatever and refernce you want to the objects
b.DS()
b.Str

As far as Best Practice I'm not sure, I need to retrieve about 6 pieces
of data, orginally tried structure but that didn't work, but found an
article on microsoft that suggeted using this.

"SMG" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> Thanks JD
>
> But for that, the end user who are using my webservices should be
> aware of such classes or I need to give that class file as well along
> with the description of the web service.
>
> Is it the right way to do it?
> what does Best Practices suggest?
>
> Regards,
> Shailesh
>
>
>
> "JD" <(E-Mail Removed)> wrote in message
> news:Xns9641EBEAE58E9invalidemailcom@199.45.49.11. ..
> You could always return a class. The code below shoe show the idea.
>
> Class ReturnMe
> public DS as Dataset
> public Str as string
> end class
>
> class WebServiceClas()
> ....
> <webmethod> public function ReturnData(...) as ReturnMe
> .....
> end class
>
> "SMG" <(E-Mail Removed)> wrote in
> news:(E-Mail Removed):
>
>>
>> Hi All,
>> I have a Web Service, which returns a DataSet and I am able to
>> consume.
>> This is ok.
>>
>> Now I want to return two things,
>> 1. DataSet
>> 2. String
>> Through one request only, I thot of using object as a return type to
>> the webservices but then how do I re cast it to string and dataset.
>> Will that work.
>> I tried with object array it didn't work with that, it says
>> "implement IConvertible"
>>
>> Any Idea how do we use and consume the same.
>>
>> Regards,
>> Shailesh Gajare
>>
>>
>>

>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
wsdl errors for multiple webservices with reference to same dataset wc_chan ASP .Net 1 12-07-2006 05:50 AM
ASP.NET 2.0 C# DataSet -> WebServices David R. ASP .Net 2 01-11-2006 07:10 AM
WebServices Return DataSet + String as Objec SMG ASP .Net Web Services 5 04-27-2005 06:12 AM
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM
Webservices XML, XSLT and the Dataset Joseph ASP .Net Web Services 0 02-17-2004 03:34 PM



Advertisments