WebServices Return DataSet + String as Object

Discussion in 'ASP .Net' started by SMG, Apr 22, 2005.

  1. SMG

    SMG Guest

    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
     
    SMG, Apr 22, 2005
    #1
    1. Advertising

  2. 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
    >
    >
    >
     
    =?Utf-8?B?UGF0cmljaw==?=, Apr 22, 2005
    #2
    1. Advertising

  3. SMG

    JD Guest

    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" <> wrote in
    news::

    >
    > 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
    >
    >
    >
     
    JD, Apr 24, 2005
    #3
  4. SMG

    SMG Guest

    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" <> 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" <> wrote in
    news::

    >
    > 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
    >
    >
    >
     
    SMG, Apr 25, 2005
    #4
  5. SMG

    JD Guest

    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" <> wrote in
    news::

    > 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" <> 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" <> wrote in
    > news::
    >
    >>
    >> 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
    >>
    >>
    >>

    >
    >
    >
     
    JD, Apr 26, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David R.

    ASP.NET 2.0 C# DataSet -> WebServices

    David R., Jan 9, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    5,780
  2. wc_chan
    Replies:
    1
    Views:
    697
    =?Utf-8?B?Q2F0YWxpbiBUb21lc2N1?=
    Dec 7, 2006
  3. Joseph

    Webservices XML, XSLT and the Dataset

    Joseph, Feb 17, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    136
    Joseph
    Feb 17, 2004
  4. Simon Storr

    Typed dataset used by two webservices problem

    Simon Storr, Feb 23, 2004, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    148
    Yan-Hong Huang[MSFT]
    Feb 26, 2004
  5. SMG

    WebServices Return DataSet + String as Objec

    SMG, Apr 22, 2005, in forum: ASP .Net Web Services
    Replies:
    5
    Views:
    209
    Ingo Eichenseher
    Apr 27, 2005
Loading...

Share This Page