webservices: simple question, accessing webservice members

Discussion in 'ASP .Net Web Services' started by hellrazor, Nov 16, 2004.

  1. hellrazor

    hellrazor Guest

    Hi, (new to webservices here)

    Is it possible to access a class instance variable defined in a webservice?
    I want to access this variable, in addition to the data being returned by
    the [webmethod].

    so let's say I have the following webservice class:


    public class Service1 : System.Web.Services.WebService
    {

    public string hello2;

    public ModelServices()
    {
    InitializeComponent();
    }

    [WebMethod]
    public string sayHello()
    {
    hello2 = "another hello to you!"
    return "hello there";
    }
    }


    ................................

    So when I consume this webservice, I want to be able to call the sayHello()
    method, and have access to the hello2 variable after having called sayHello
    () and thus expecting the "hello2" variable to contain the "another hello
    to you!" value:


    remoteWS.Service1 ws = new remoteWS.Service1();
    string hello1 = ws.sayHello();
    string hello2 = ws.hello2;



    Is this possible, and how do I go about doing it? thanks!
     
    hellrazor, Nov 16, 2004
    #1
    1. Advertising

  2. hellrazor

    Dan Rogers Guest

    Hi Jorge,

    As you've already found out, the code you showed works fine. What you are
    trying to do, however, is to implement static or shared data (singleton)
    behaviors across all instances of a service method call. As such, the code
    you are trying will not work between method invocations - but it WILL work
    for a single method invocation.

    The web service class you write is a facade of sorts that lets a stateless
    method call be dispatched from a remote caller. As such, a new instance of
    the web service class is implemented for each method call. You can prove
    this by putting a debug break point on the IntializeComponent call in the
    constructor. Each time any service method is invoked, the constructor is
    called - which means that each call to the web service entry point cause a
    new invocation of the class to be constructed.

    To get a shared data behavior, you either have to implement applicaiton
    state (within IIS) or use some other successful singleton pattern
    implementation outside of your web service class. This could be a
    database, a COM+ component, or some other in memory persistent store that
    you can access from your own code.

    I hope this helps,

    Dan Rogers
    Microsoft Corporation
    --------------------
    >Subject: webservices: simple question, accessing webservice members
    >From: hellrazor <>
    >Organization: packet monkeys inc.
    >Message-ID: <Xns95A2AE03D3856jorgeanotherworldcom@207.46.248.16>
    >User-Agent: Xnews/5.04.25
    >Newsgroups:

    microsoft.public.dotnet.languages.csharp,microsoft.public.dotnet.framework.w
    ebservices,microsoft.public.dotnet.framework.aspnet.webservices
    >Date: Mon, 15 Nov 2004 17:01:25 -0800
    >NNTP-Posting-Host: s0106000625d84bd8.vn.shawcable.net 24.86.11.226
    >Lines: 1
    >Path:

    cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12
    .phx.gbl
    >Xref: cpmsftngxa10.phx.gbl

    microsoft.public.dotnet.framework.webservices:7454
    microsoft.public.dotnet.framework.aspnet.webservices:26582
    microsoft.public.dotnet.languages.csharp:286847
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    >
    >Hi, (new to webservices here)
    >
    >Is it possible to access a class instance variable defined in a

    webservice?
    >I want to access this variable, in addition to the data being returned by
    >the [webmethod].
    >
    >so let's say I have the following webservice class:
    >
    >
    > public class Service1 : System.Web.Services.WebService
    > {
    >
    > public string hello2;
    >
    > public ModelServices()
    > {
    > InitializeComponent();
    > }
    >
    > [WebMethod]
    > public string sayHello()
    > {
    > hello2 = "another hello to you!"
    > return "hello there";
    > }
    > }
    >
    >
    >...............................
    >
    >So when I consume this webservice, I want to be able to call the

    sayHello()
    >method, and have access to the hello2 variable after having called sayHello
    >() and thus expecting the "hello2" variable to contain the "another hello
    >to you!" value:
    >
    >
    >remoteWS.Service1 ws = new remoteWS.Service1();
    >string hello1 = ws.sayHello();
    >string hello2 = ws.hello2;
    >
    >
    >
    >Is this possible, and how do I go about doing it? thanks!
    >
    >
    >
     
    Dan Rogers, Nov 16, 2004
    #2
    1. Advertising

  3. I don't think you can access a public member of
    System.Web.Services.WebService class from a client side. I would either
    stored the value in database or use Session in the web service.

    Good luck!

    ============================
    Hayato Iriumi ()
    Blog: http://www.vbaspcoder.com


    "hellrazor" <> wrote in message
    news:Xns95A2AE03D3856jorgeanotherworldcom@207.46.248.16...
    > Hi, (new to webservices here)
    >
    > Is it possible to access a class instance variable defined in a

    webservice?
    > I want to access this variable, in addition to the data being returned by
    > the [webmethod].
    >
    > so let's say I have the following webservice class:
    >
    >
    > public class Service1 : System.Web.Services.WebService
    > {
    >
    > public string hello2;
    >
    > public ModelServices()
    > {
    > InitializeComponent();
    > }
    >
    > [WebMethod]
    > public string sayHello()
    > {
    > hello2 = "another hello to you!"
    > return "hello there";
    > }
    > }
    >
    >
    > ...............................
    >
    > So when I consume this webservice, I want to be able to call the

    sayHello()
    > method, and have access to the hello2 variable after having called

    sayHello
    > () and thus expecting the "hello2" variable to contain the "another hello
    > to you!" value:
    >
    >
    > remoteWS.Service1 ws = new remoteWS.Service1();
    > string hello1 = ws.sayHello();
    > string hello2 = ws.hello2;
    >
    >
    >
    > Is this possible, and how do I go about doing it? thanks!
    >
    >
     
    Hayato Iriumi, Nov 16, 2004
    #3
  4. hellrazor

    Nick Malik Guest

    you can either add another webmethod to return the new value (which is
    chatty and inefficient) or you can return a class that contains both values.

    For example:

    public class SharedClass
    {
    string MyHello1;
    string MyHello2;
    }

    public class Service1: System.Web.Services.WebService
    {
    // put initializer here... ommitted for brevity
    [WebMethod]
    public SharedClass SayHello()
    {
    SharedClass sc = new SharedClass();
    sc.MyHello1 = "Hello There";
    sc.MyHello2 = "And Again";
    }
    }

    public class WebClient
    {
    public void MyClient()
    {
    Service1 mywebservice;
    mywebservice.SayHello();
    Console.WriteLine("{0}", mywebservice.MyHello1);
    Console.WriteLine("{0}", mywebservice.MyHello2);
    }
    }

    ((Caveat: this code is from the top of my head... it has not been
    compiled... please excuse typos))

    Hope this helps,
    --- Nick

    "hellrazor" <> wrote in message
    news:Xns95A2AE03D3856jorgeanotherworldcom@207.46.248.16...
    > Hi, (new to webservices here)
    >
    > Is it possible to access a class instance variable defined in a

    webservice?
    > I want to access this variable, in addition to the data being returned by
    > the [webmethod].
    >
    > so let's say I have the following webservice class:
    >
    >
    > public class Service1 : System.Web.Services.WebService
    > {
    >
    > public string hello2;
    >
    > public ModelServices()
    > {
    > InitializeComponent();
    > }
    >
    > [WebMethod]
    > public string sayHello()
    > {
    > hello2 = "another hello to you!"
    > return "hello there";
    > }
    > }
    >
    >
    > ...............................
    >
    > So when I consume this webservice, I want to be able to call the

    sayHello()
    > method, and have access to the hello2 variable after having called

    sayHello
    > () and thus expecting the "hello2" variable to contain the "another hello
    > to you!" value:
    >
    >
    > remoteWS.Service1 ws = new remoteWS.Service1();
    > string hello1 = ws.sayHello();
    > string hello2 = ws.hello2;
    >
    >
    >
    > Is this possible, and how do I go about doing it? thanks!
    >
    >
     
    Nick Malik, Nov 16, 2004
    #4
  5. hellrazor

    Nick Malik Guest

    I screwed up a bit of that code.

    Please replace the client class as follows:

    public void MyClient()
    {
    Service1 mywebservice;
    SharedClass myShared;
    myShared = mywebservice.SayHello();
    Console.WriteLine("{0}", myShared.MyHello1);
    Console.WriteLine("{0}", myShared.MyHello2);
    }

    Sorry about that.

    --- Nick

    "Nick Malik" <> wrote in message
    news:GKomd.513423$mD.491984@attbi_s02...
    > you can either add another webmethod to return the new value (which is
    > chatty and inefficient) or you can return a class that contains both

    values.
    >
    > For example:
    >
    > public class SharedClass
    > {
    > string MyHello1;
    > string MyHello2;
    > }
    >
    > public class Service1: System.Web.Services.WebService
    > {
    > // put initializer here... ommitted for brevity
    > [WebMethod]
    > public SharedClass SayHello()
    > {
    > SharedClass sc = new SharedClass();
    > sc.MyHello1 = "Hello There";
    > sc.MyHello2 = "And Again";
    > }
    > }
    >
    > public class WebClient
    > {
    > public void MyClient()
    > {
    > Service1 mywebservice;
    > mywebservice.SayHello();
    > Console.WriteLine("{0}", mywebservice.MyHello1);
    > Console.WriteLine("{0}", mywebservice.MyHello2);
    > }
    > }
    >
    > ((Caveat: this code is from the top of my head... it has not been
    > compiled... please excuse typos))
    >
    > Hope this helps,
    > --- Nick
    >
    > "hellrazor" <> wrote in message
    > news:Xns95A2AE03D3856jorgeanotherworldcom@207.46.248.16...
    > > Hi, (new to webservices here)
    > >
    > > Is it possible to access a class instance variable defined in a

    > webservice?
    > > I want to access this variable, in addition to the data being returned

    by
    > > the [webmethod].
    > >
    > > so let's say I have the following webservice class:
    > >
    > >
    > > public class Service1 : System.Web.Services.WebService
    > > {
    > >
    > > public string hello2;
    > >
    > > public ModelServices()
    > > {
    > > InitializeComponent();
    > > }
    > >
    > > [WebMethod]
    > > public string sayHello()
    > > {
    > > hello2 = "another hello to you!"
    > > return "hello there";
    > > }
    > > }
    > >
    > >
    > > ...............................
    > >
    > > So when I consume this webservice, I want to be able to call the

    > sayHello()
    > > method, and have access to the hello2 variable after having called

    > sayHello
    > > () and thus expecting the "hello2" variable to contain the "another

    hello
    > > to you!" value:
    > >
    > >
    > > remoteWS.Service1 ws = new remoteWS.Service1();
    > > string hello1 = ws.sayHello();
    > > string hello2 = ws.hello2;
    > >
    > >
    > >
    > > Is this possible, and how do I go about doing it? thanks!
    > >
    > >

    >
    >
     
    Nick Malik, Nov 16, 2004
    #5
  6. hellrazor

    hellrazor Guest

    "Nick Malik" <> wrote in news:q9pmd.46404
    $5K2.39317@attbi_s03:

    > I screwed up a bit of that code.
    >
    > Please replace the client class as follows:
    >
    > public void MyClient()
    > {
    > Service1 mywebservice;
    > SharedClass myShared;
    > myShared = mywebservice.SayHello();
    > Console.WriteLine("{0}", myShared.MyHello1);
    > Console.WriteLine("{0}", myShared.MyHello2);
    > }
    >
    > Sorry about that.
    >
    > --- Nick
    >
    > "Nick Malik" <> wrote in message
    > news:GKomd.513423$mD.491984@attbi_s02...
    >> you can either add another webmethod to return the new value (which is
    >> chatty and inefficient) or you can return a class that contains both

    > values.
    >>
    >> For example:
    >>
    >> public class SharedClass
    >> {
    >> string MyHello1;
    >> string MyHello2;
    >> }
    >>
    >> public class Service1: System.Web.Services.WebService
    >> {
    >> // put initializer here... ommitted for brevity
    >> [WebMethod]
    >> public SharedClass SayHello()
    >> {
    >> SharedClass sc = new SharedClass();
    >> sc.MyHello1 = "Hello There";
    >> sc.MyHello2 = "And Again";
    >> }
    >> }
    >>
    >> public class WebClient
    >> {
    >> public void MyClient()
    >> {
    >> Service1 mywebservice;
    >> mywebservice.SayHello();
    >> Console.WriteLine("{0}", mywebservice.MyHello1);
    >> Console.WriteLine("{0}", mywebservice.MyHello2);
    >> }
    >> }
    >>
    >> ((Caveat: this code is from the top of my head... it has not been
    >> compiled... please excuse typos))
    >>
    >> Hope this helps,
    >> --- Nick
    >>
    >> "hellrazor" <> wrote in message
    >> news:Xns95A2AE03D3856jorgeanotherworldcom@207.46.248.16...
    >> > Hi, (new to webservices here)
    >> >
    >> > Is it possible to access a class instance variable defined in a

    >> webservice?
    >> > I want to access this variable, in addition to the data being

    returned
    > by
    >> > the [webmethod].
    >> >
    >> > so let's say I have the following webservice class:
    >> >
    >> >
    >> > public class Service1 : System.Web.Services.WebService
    >> > {
    >> >
    >> > public string hello2;
    >> >
    >> > public ModelServices()
    >> > {
    >> > InitializeComponent();
    >> > }
    >> >
    >> > [WebMethod]
    >> > public string sayHello()
    >> > {
    >> > hello2 = "another hello to you!"
    >> > return "hello there";
    >> > }
    >> > }
    >> >
    >> >
    >> > ...............................
    >> >
    >> > So when I consume this webservice, I want to be able to call the

    >> sayHello()
    >> > method, and have access to the hello2 variable after having called

    >> sayHello
    >> > () and thus expecting the "hello2" variable to contain the "another

    > hello
    >> > to you!" value:
    >> >
    >> >
    >> > remoteWS.Service1 ws = new remoteWS.Service1();
    >> > string hello1 = ws.sayHello();
    >> > string hello2 = ws.hello2;
    >> >
    >> >
    >> >
    >> > Is this possible, and how do I go about doing it? thanks!
    >> >
    >> >

    >>
    >>

    >
    >
    >


    Hi there, thanks!

    When I try to compile the client application in VS, I get the following
    error:

    C:\clients\test.cs(1070): Cannot implicitly convert type
    'WS.ReturnValuesClass' to 'MyApp.ReturnValuesClass'


    I have placed the class in the source code for both the webservice and
    the client. Is there anything specific involved that I have missed?

    Thanks!

    Jorge
     
    hellrazor, Nov 16, 2004
    #6
  7. hellrazor

    Dan Rogers Guest

    Hi Jorge,

    It seems you are trying to use the service class as a stateful remote
    object. This isn't going to work, since you cannot access members on the
    service class in the way you are trying to.

    A service method takes input parameters and returns values either thru its
    parameter list or via it's return type. Think of the method like you would
    a function in a function library and not having any access to state on the
    server side (which for the most part is not kept).

    This means you need to pass in parameters and get back data that you are
    going to use, and not expect the web serivice proxy to have any internal
    knowlege about the work done on the server side.

    I hope this helps

    Dan Rogers
    Microsoft Corporation

    >
    >Hi there, thanks!
    >
    >When I try to compile the client application in VS, I get the following
    >error:
    >
    >C:\clients\test.cs(1070): Cannot implicitly convert type
    >'WS.ReturnValuesClass' to 'MyApp.ReturnValuesClass'
    >
    >
    >I have placed the class in the source code for both the webservice and
    >the client. Is there anything specific involved that I have missed?
    >
    >Thanks!
    >
    >Jorge
    >
     
    Dan Rogers, Nov 16, 2004
    #7
  8. hellrazor

    Nick Malik Guest

    <clip ...>

    > Hi there, thanks!
    >
    > When I try to compile the client application in VS, I get the following
    > error:
    >
    > C:\clients\test.cs(1070): Cannot implicitly convert type
    > 'WS.ReturnValuesClass' to 'MyApp.ReturnValuesClass'
    >
    >
    > I have placed the class in the source code for both the webservice and
    > the client. Is there anything specific involved that I have missed?
    >
    > Thanks!
    >
    > Jorge


    Hi Jorge,

    That's what I get for not compiling the code first. My apologies.

    The shared class should NOT be declared again in the client code. The
    definition of the shared class is passed via the WSDL and is coded in the
    web service generated code. You can simply declare a variable of type
    WS.ReturnValuesClass and refer to the members that way.

    If you want to see the code the Visual Studio generates for you when you
    make a web reference, then look carefully at your project explorer window.
    There are a couple of small icons in the bar just above the treeview of your
    solution and project(s). One of the icons, if you hover over it, says
    something like "show all files". Click it. Then look into the client
    project. You will see a new code file under the web reference to the web
    service. In there, you will see the definition of the shared class.

    Good Luck,
    --- Nick
     
    Nick Malik, Nov 17, 2004
    #8
  9. hellrazor

    hellrazor Guest

    (Dan Rogers) wrote in
    news::

    > Hi Jorge,
    >
    > It seems you are trying to use the service class as a stateful remote
    > object. This isn't going to work, since you cannot access members on
    > the service class in the way you are trying to.
    >
    > A service method takes input parameters and returns values either thru
    > its parameter list or via it's return type. Think of the method like
    > you would a function in a function library and not having any access
    > to state on the server side (which for the most part is not kept).
    >
    > This means you need to pass in parameters and get back data that you
    > are going to use, and not expect the web serivice proxy to have any
    > internal knowlege about the work done on the server side.
    >
    > I hope this helps
    >
    > Dan Rogers
    > Microsoft Corporation
    >
    >>
    >>Hi there, thanks!
    >>
    >>When I try to compile the client application in VS, I get the
    >>following error:
    >>
    >>C:\clients\test.cs(1070): Cannot implicitly convert type
    >>'WS.ReturnValuesClass' to 'MyApp.ReturnValuesClass'
    >>
    >>
    >>I have placed the class in the source code for both the webservice and
    >>the client. Is there anything specific involved that I have missed?
    >>
    >>Thanks!
    >>
    >>Jorge
    >>

    >


    Hi there,

    I'm not really trying to use it as a "state" object. Basically, I just
    want to return the values I set within the webservice call. I tried
    returning a simple Object[] array and that seemed to work. It was a
    variable type array, example:

    [WebMethod]
    public Object[] myTestWSClass()
    {
    int intValue1 = 1;
    string strValue1 = "hello there";
    double dblValue1 = 2.3;
    Object[] retObjArray = {intValue1 , strValue1 , dblValue1};

    return retObjArray;

    }



    What I wanted to do is perhaps have a class to hold my values:

    public class ReturnValuesClass
    {
    int intValue1 = 1;
    string strValue1 = "hello there";
    double dblValue1 = 2.3;}

    and modify my webmethod function to return an instance of the class

    [WebMethod]
    public ReturnValuesClass myTestWSClass()
    {
    ReturnValuesClass retClassObj = new ReturnValuesClass();
    retClassObj.intValue1 = 1;
    retClassObj.strValue1 = "hello there";
    retClassObj.dblValue1 = 2.3;
    return retClassObj;

    }



    I think this would qualify as "stateless" since I'm not setting the
    values and expecting the retrieve them at a later time.. I just wanted a
    more elegant way of returning my values than using an Object array (which
    works for now)

    Jorge
     
    hellrazor, Nov 17, 2004
    #9
  10. hellrazor

    hellrazor Guest

    (Dan Rogers) wrote in
    news::

    > Hi Jorge,
    >
    > It seems you are trying to use the service class as a stateful remote
    > object. This isn't going to work, since you cannot access members on
    > the service class in the way you are trying to.
    >
    > A service method takes input parameters and returns values either thru
    > its parameter list or via it's return type. Think of the method like
    > you would a function in a function library and not having any access
    > to state on the server side (which for the most part is not kept).
    >
    > This means you need to pass in parameters and get back data that you
    > are going to use, and not expect the web serivice proxy to have any
    > internal knowlege about the work done on the server side.
    >
    > I hope this helps
    >
    > Dan Rogers
    > Microsoft Corporation
    >
    >>
    >>Hi there, thanks!
    >>
    >>When I try to compile the client application in VS, I get the
    >>following error:
    >>
    >>C:\clients\test.cs(1070): Cannot implicitly convert type
    >>'WS.ReturnValuesClass' to 'MyApp.ReturnValuesClass'
    >>
    >>
    >>I have placed the class in the source code for both the webservice and
    >>the client. Is there anything specific involved that I have missed?
    >>
    >>Thanks!
    >>
    >>Jorge
    >>

    >


    Hi,

    That worked, thanks!

    I need to get me a propper webservices tutorial / book. This "Webservices
    for dummies" book is alright, but it just touches the surface. It's only
    got a couple of pages worth of actual code.

    Jorge
     
    hellrazor, Nov 17, 2004
    #10
  11. hellrazor

    Dan Rogers Guest

    In general, you have to consider each method call to cause a new instance
    of the server-side class. This instance is created to service the request.
    The logic in your calling code that creates a new instance is really
    creating an instance of a proxy for the server side object. It is that
    proxy that forms the request and fields the response from the new instance
    of the server side object.

    So even though on the calling side you are using the same class to dispatch
    two calls, on the server side, there is a new instance of the object being
    made or each call. This is why the data passing you were expecting doesn't
    work.

    The array approach works because it happens in one round trip. You can
    certanly create a complex class that is not an array, populate an instance
    of that class in a single method call, and then have that class returned.
    If you then want a different method to add data to the "return value
    class", you will have to pass the data to the second method so that it can
    effect the same instance of the answer.

    I hope this helps

    Dan Rogers
    Microsoft Corporation
    --------------------
    >Subject: Re: webservices: simple question, accessing webservice members
    >From: hellrazor <>
    >References: <Xns95A2AE03D3856jorgeanotherworldcom@207.46.248.16>

    <GKomd.513423$mD.491984@attbi_s02> <q9pmd.46404$5K2.39317@attbi_s03>
    <Xns95A374553D7D2jorgeanotherworldcom@207.46.248.16>
    <>
    >Organization: packet monkeys inc.
    >Message-ID: <Xns95A4969DF610Djorgeanotherworldcom@207.46.248.16>
    >User-Agent: Xnews/5.04.25
    >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    >Date: Wed, 17 Nov 2004 14:43:23 -0800
    >NNTP-Posting-Host: s0106000625d84bd8.vn.shawcable.net 24.86.11.226
    >Lines: 1
    >Path:

    cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14
    phx.gbl
    >Xref: cpmsftngxa10.phx.gbl

    microsoft.public.dotnet.framework.aspnet.webservices:26673
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    >
    > (Dan Rogers) wrote in
    >news::
    >
    >> Hi Jorge,
    >>
    >> It seems you are trying to use the service class as a stateful remote
    >> object. This isn't going to work, since you cannot access members on
    >> the service class in the way you are trying to.
    >>
    >> A service method takes input parameters and returns values either thru
    >> its parameter list or via it's return type. Think of the method like
    >> you would a function in a function library and not having any access
    >> to state on the server side (which for the most part is not kept).
    >>
    >> This means you need to pass in parameters and get back data that you
    >> are going to use, and not expect the web serivice proxy to have any
    >> internal knowlege about the work done on the server side.
    >>
    >> I hope this helps
    >>
    >> Dan Rogers
    >> Microsoft Corporation
    >>
    >>>
    >>>Hi there, thanks!
    >>>
    >>>When I try to compile the client application in VS, I get the
    >>>following error:
    >>>
    >>>C:\clients\test.cs(1070): Cannot implicitly convert type
    >>>'WS.ReturnValuesClass' to 'MyApp.ReturnValuesClass'
    >>>
    >>>
    >>>I have placed the class in the source code for both the webservice and
    >>>the client. Is there anything specific involved that I have missed?
    >>>
    >>>Thanks!
    >>>
    >>>Jorge
    >>>

    >>

    >
    >Hi there,
    >
    >I'm not really trying to use it as a "state" object. Basically, I just
    >want to return the values I set within the webservice call. I tried
    >returning a simple Object[] array and that seemed to work. It was a
    >variable type array, example:
    >
    >[WebMethod]
    >public Object[] myTestWSClass()
    >{
    > int intValue1 = 1;
    > string strValue1 = "hello there";
    > double dblValue1 = 2.3;
    > Object[] retObjArray = {intValue1 , strValue1 , dblValue1};
    >
    > return retObjArray;
    >
    >}
    >
    >
    >
    >What I wanted to do is perhaps have a class to hold my values:
    >
    >public class ReturnValuesClass
    >{
    > int intValue1 = 1;
    > string strValue1 = "hello there";
    > double dblValue1 = 2.3;}
    >
    >and modify my webmethod function to return an instance of the class
    >
    >[WebMethod]
    >public ReturnValuesClass myTestWSClass()
    >{
    > ReturnValuesClass retClassObj = new ReturnValuesClass();
    > retClassObj.intValue1 = 1;
    > retClassObj.strValue1 = "hello there";
    > retClassObj.dblValue1 = 2.3;
    > return retClassObj;
    >
    >}
    >
    >
    >
    >I think this would qualify as "stateless" since I'm not setting the
    >values and expecting the retrieve them at a later time.. I just wanted a
    >more elegant way of returning my values than using an Object array (which
    >works for now)
    >
    >Jorge
    >
     
    Dan Rogers, Nov 18, 2004
    #11
    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. JFCM
    Replies:
    4
    Views:
    5,778
  2. CoolPint
    Replies:
    8
    Views:
    1,027
    Jeff Schwab
    Dec 14, 2003
  3. Dave
    Replies:
    3
    Views:
    384
    tom_usenet
    Aug 10, 2004
  4. hdixon
    Replies:
    3
    Views:
    673
    hdixon
    Jul 9, 2006
  5. lovecreatesbeauty
    Replies:
    43
    Views:
    1,322
    Keith Thompson
    Feb 6, 2006
Loading...

Share This Page