Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Web service instance still alive?

Reply
Thread Tools

Web service instance still alive?

 
 
Mantorok
Guest
Posts: n/a
 
      06-01-2007
Hi

C# 2.0.

I have an instance of a web-service assigned to a field, how would I know if
the session has timed-out on that web-service? Is there anyway of checking
this?

Thanks
Kev


 
Reply With Quote
 
 
 
 
John Saunders [MVP]
Guest
Posts: n/a
 
      06-02-2007
"Mantorok" <****@****.com> wrote in message news:465fed49@212.67.96.135...
> Hi
>
> C# 2.0.
>
> I have an instance of a web-service assigned to a field, how would I know
> if the session has timed-out on that web-service? Is there anyway of
> checking this?


When you say, "session", are you referring to session variables, or to the
TCP/IP connection?

If you're referring to the connection, I think the only way to know if it's
still open is to use it.

I think it's likely to be the same story for session variables.
--
John Saunders [MVP]


 
Reply With Quote
 
 
 
 
Mantorok
Guest
Posts: n/a
 
      06-04-2007

"John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message
news:...
> "Mantorok" <****@****.com> wrote in message news:465fed49@212.67.96.135...
>> Hi
>>
>> C# 2.0.
>>
>> I have an instance of a web-service assigned to a field, how would I know
>> if the session has timed-out on that web-service? Is there anyway of
>> checking this?

>
> When you say, "session", are you referring to session variables, or to the
> TCP/IP connection?


Session variables, if I don't access my web-service for 20 minutes and then
attempt to access it I get "Object reference not set to an instance of an
object" exception returned from the service.

So if my session time elapses how would I know without it throwing an
exception?

Thanks
Kev


 
Reply With Quote
 
John Saunders [MVP]
Guest
Posts: n/a
 
      06-04-2007
"Mantorok" <> wrote in message
news:f40jgb$8oh$...
>
> "John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message
> news:...
>> "Mantorok" <****@****.com> wrote in message
>> news:465fed49@212.67.96.135...
>>> Hi
>>>
>>> C# 2.0.
>>>
>>> I have an instance of a web-service assigned to a field, how would I
>>> know if the session has timed-out on that web-service? Is there anyway
>>> of checking this?

>>
>> When you say, "session", are you referring to session variables, or to
>> the TCP/IP connection?

>
> Session variables, if I don't access my web-service for 20 minutes and
> then attempt to access it I get "Object reference not set to an instance
> of an object" exception returned from the service.
>
> So if my session time elapses how would I know without it throwing an
> exception?


You should always check to see if session variables are present before
accessing them. I bet you're doing something like:

string variable = Session["Variable"];
if (variable.Length == 0) // If session expired, BOOM

Instead, use String.IsNullOrEmpty(variable) to check. Then do something
intelligent if you find that the session has expired.
--
John Saunders [MVP]


 
Reply With Quote
 
Mantorok
Guest
Posts: n/a
 
      06-04-2007

"John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message
news:...
> "Mantorok" <> wrote in message
> news:f40jgb$8oh$...
>>
>> "John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message
>> news:...
>>> "Mantorok" <****@****.com> wrote in message
>>> news:465fed49@212.67.96.135...
>>>> Hi
>>>>
>>>> C# 2.0.
>>>>
>>>> I have an instance of a web-service assigned to a field, how would I
>>>> know if the session has timed-out on that web-service? Is there anyway
>>>> of checking this?
>>>
>>> When you say, "session", are you referring to session variables, or to
>>> the TCP/IP connection?

>>
>> Session variables, if I don't access my web-service for 20 minutes and
>> then attempt to access it I get "Object reference not set to an instance
>> of an object" exception returned from the service.
>>
>> So if my session time elapses how would I know without it throwing an
>> exception?

>
> You should always check to see if session variables are present before
> accessing them. I bet you're doing something like:
>
> string variable = Session["Variable"];
> if (variable.Length == 0) // If session expired, BOOM
>
> Instead, use String.IsNullOrEmpty(variable) to check. Then do something
> intelligent if you find that the session has expired.


Yes, that is what's happening.

The problem is, the web-service is not self-initialising, it must be
"activated" by the client before it can begin to accept certain requests,
this is a bit of a security step to stop any tom, dick and harry from
accessing my service and potentially obtaining sensitive data.

This is why I need to somehow check at the client end, if it has ended I
need to re-activate the service so that I can continue to use it.

Thanks
Kev


 
Reply With Quote
 
John Saunders [MVP]
Guest
Posts: n/a
 
      06-04-2007
"Mantorok" <> wrote in message
news:f412u3$i8d$...
>
> "John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message
> news:...
>> "Mantorok" <> wrote in message
>> news:f40jgb$8oh$...
>>>
>>> "John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message
>>> news:...
>>>> "Mantorok" <****@****.com> wrote in message
>>>> news:465fed49@212.67.96.135...
>>>>> Hi
>>>>>
>>>>> C# 2.0.
>>>>>
>>>>> I have an instance of a web-service assigned to a field, how would I
>>>>> know if the session has timed-out on that web-service? Is there
>>>>> anyway of checking this?
>>>>
>>>> When you say, "session", are you referring to session variables, or to
>>>> the TCP/IP connection?
>>>
>>> Session variables, if I don't access my web-service for 20 minutes and
>>> then attempt to access it I get "Object reference not set to an instance
>>> of an object" exception returned from the service.
>>>
>>> So if my session time elapses how would I know without it throwing an
>>> exception?

>>
>> You should always check to see if session variables are present before
>> accessing them. I bet you're doing something like:
>>
>> string variable = Session["Variable"];
>> if (variable.Length == 0) // If session expired, BOOM
>>
>> Instead, use String.IsNullOrEmpty(variable) to check. Then do something
>> intelligent if you find that the session has expired.

>
> Yes, that is what's happening.
>
> The problem is, the web-service is not self-initialising, it must be
> "activated" by the client before it can begin to accept certain requests,
> this is a bit of a security step to stop any tom, dick and harry from
> accessing my service and potentially obtaining sensitive data.
>
> This is why I need to somehow check at the client end, if it has ended I
> need to re-activate the service so that I can continue to use it.


No. Have the server detect session expiration. That is a server-side
concept. Have the server return the client a message saying that the client
needs to re-initialize.

This message may be sent via a SOAP Fault element by throwing a
SoapException. You may populate the Details property of the SoapException to
provide the client with details about what happened.
--
John Saunders [MVP]


 
Reply With Quote
 
Mantorok
Guest
Posts: n/a
 
      06-04-2007

"John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message
news:...
> "Mantorok" <> wrote in message
> news:f412u3$i8d$...
>>
>> "John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message
>> news:...
>>> "Mantorok" <> wrote in message
>>> news:f40jgb$8oh$...
>>>>
>>>> "John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message
>>>> news:...
>>>>> "Mantorok" <****@****.com> wrote in message
>>>>> news:465fed49@212.67.96.135...
>>>>>> Hi
>>>>>>
>>>>>> C# 2.0.
>>>>>>
>>>>>> I have an instance of a web-service assigned to a field, how would I
>>>>>> know if the session has timed-out on that web-service? Is there
>>>>>> anyway of checking this?
>>>>>
>>>>> When you say, "session", are you referring to session variables, or to
>>>>> the TCP/IP connection?
>>>>
>>>> Session variables, if I don't access my web-service for 20 minutes and
>>>> then attempt to access it I get "Object reference not set to an
>>>> instance of an object" exception returned from the service.
>>>>
>>>> So if my session time elapses how would I know without it throwing an
>>>> exception?
>>>
>>> You should always check to see if session variables are present before
>>> accessing them. I bet you're doing something like:
>>>
>>> string variable = Session["Variable"];
>>> if (variable.Length == 0) // If session expired, BOOM
>>>
>>> Instead, use String.IsNullOrEmpty(variable) to check. Then do something
>>> intelligent if you find that the session has expired.

>>
>> Yes, that is what's happening.
>>
>> The problem is, the web-service is not self-initialising, it must be
>> "activated" by the client before it can begin to accept certain requests,
>> this is a bit of a security step to stop any tom, dick and harry from
>> accessing my service and potentially obtaining sensitive data.
>>
>> This is why I need to somehow check at the client end, if it has ended I
>> need to re-activate the service so that I can continue to use it.

>
> No. Have the server detect session expiration. That is a server-side
> concept. Have the server return the client a message saying that the
> client needs to re-initialize.
>
> This message may be sent via a SOAP Fault element by throwing a
> SoapException. You may populate the Details property of the SoapException
> to provide the client with details about what happened.


Ah, you have a point there, I could catch the exception at the client-side
and re-initialise for that particular fault.

Is there anything else I need to be aware of or is it just a standard
throw-catch scenario? Do I just check the Details property and handle
accordingly?

Thanks
Kev


 
Reply With Quote
 
John Saunders [MVP]
Guest
Posts: n/a
 
      06-04-2007
"Mantorok" <> wrote in message
news:46646c47@212.67.96.135...
>
> "John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message
> news:...
>> "Mantorok" <> wrote in message
>> news:f412u3$i8d$...
>>>
>>> "John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message
>>> news:...
>>>> "Mantorok" <> wrote in message
>>>> news:f40jgb$8oh$...
>>>>>
>>>>> "John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message
>>>>> news:...
>>>>>> "Mantorok" <****@****.com> wrote in message
>>>>>> news:465fed49@212.67.96.135...
>>>>>>> Hi
>>>>>>>
>>>>>>> C# 2.0.
>>>>>>>
>>>>>>> I have an instance of a web-service assigned to a field, how would I
>>>>>>> know if the session has timed-out on that web-service? Is there
>>>>>>> anyway of checking this?
>>>>>>
>>>>>> When you say, "session", are you referring to session variables, or
>>>>>> to the TCP/IP connection?
>>>>>
>>>>> Session variables, if I don't access my web-service for 20 minutes and
>>>>> then attempt to access it I get "Object reference not set to an
>>>>> instance of an object" exception returned from the service.
>>>>>
>>>>> So if my session time elapses how would I know without it throwing an
>>>>> exception?
>>>>
>>>> You should always check to see if session variables are present before
>>>> accessing them. I bet you're doing something like:
>>>>
>>>> string variable = Session["Variable"];
>>>> if (variable.Length == 0) // If session expired, BOOM
>>>>
>>>> Instead, use String.IsNullOrEmpty(variable) to check. Then do something
>>>> intelligent if you find that the session has expired.
>>>
>>> Yes, that is what's happening.
>>>
>>> The problem is, the web-service is not self-initialising, it must be
>>> "activated" by the client before it can begin to accept certain
>>> requests, this is a bit of a security step to stop any tom, dick and
>>> harry from accessing my service and potentially obtaining sensitive
>>> data.
>>>
>>> This is why I need to somehow check at the client end, if it has ended I
>>> need to re-activate the service so that I can continue to use it.

>>
>> No. Have the server detect session expiration. That is a server-side
>> concept. Have the server return the client a message saying that the
>> client needs to re-initialize.
>>
>> This message may be sent via a SOAP Fault element by throwing a
>> SoapException. You may populate the Details property of the SoapException
>> to provide the client with details about what happened.

>
> Ah, you have a point there, I could catch the exception at the client-side
> and re-initialise for that particular fault.
>
> Is there anything else I need to be aware of or is it just a standard
> throw-catch scenario? Do I just check the Details property and handle
> accordingly?


The trick is that any unhandled exception thrown in your service will be
turned into a SoapException with no details - except for a real
SoapException. In that case, you can fill the Details property with whatever
XML you need to tell the client what happened.
--
John Saunders [MVP]


 
Reply With Quote
 
Mantorok
Guest
Posts: n/a
 
      06-06-2007

"John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message
news:%23k0%...
> "Mantorok" <> wrote in message
> news:46646c47@212.67.96.135...
>>
>> "John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message
>> news:...
>>> "Mantorok" <> wrote in message
>>> news:f412u3$i8d$...
>>>>
>>>> "John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message
>>>> news:...
>>>>> "Mantorok" <> wrote in message
>>>>> news:f40jgb$8oh$...
>>>>>>
>>>>>> "John Saunders [MVP]" <john.saunders at trizetto.com> wrote in
>>>>>> message news:...
>>>>>>> "Mantorok" <****@****.com> wrote in message
>>>>>>> news:465fed49@212.67.96.135...
>>>>>>>> Hi
>>>>>>>>
>>>>>>>> C# 2.0.
>>>>>>>>
>>>>>>>> I have an instance of a web-service assigned to a field, how would
>>>>>>>> I know if the session has timed-out on that web-service? Is there
>>>>>>>> anyway of checking this?
>>>>>>>
>>>>>>> When you say, "session", are you referring to session variables, or
>>>>>>> to the TCP/IP connection?
>>>>>>
>>>>>> Session variables, if I don't access my web-service for 20 minutes
>>>>>> and then attempt to access it I get "Object reference not set to an
>>>>>> instance of an object" exception returned from the service.
>>>>>>
>>>>>> So if my session time elapses how would I know without it throwing an
>>>>>> exception?
>>>>>
>>>>> You should always check to see if session variables are present before
>>>>> accessing them. I bet you're doing something like:
>>>>>
>>>>> string variable = Session["Variable"];
>>>>> if (variable.Length == 0) // If session expired, BOOM
>>>>>
>>>>> Instead, use String.IsNullOrEmpty(variable) to check. Then do
>>>>> something intelligent if you find that the session has expired.
>>>>
>>>> Yes, that is what's happening.
>>>>
>>>> The problem is, the web-service is not self-initialising, it must be
>>>> "activated" by the client before it can begin to accept certain
>>>> requests, this is a bit of a security step to stop any tom, dick and
>>>> harry from accessing my service and potentially obtaining sensitive
>>>> data.
>>>>
>>>> This is why I need to somehow check at the client end, if it has ended
>>>> I need to re-activate the service so that I can continue to use it.
>>>
>>> No. Have the server detect session expiration. That is a server-side
>>> concept. Have the server return the client a message saying that the
>>> client needs to re-initialize.
>>>
>>> This message may be sent via a SOAP Fault element by throwing a
>>> SoapException. You may populate the Details property of the
>>> SoapException to provide the client with details about what happened.

>>
>> Ah, you have a point there, I could catch the exception at the
>> client-side and re-initialise for that particular fault.
>>
>> Is there anything else I need to be aware of or is it just a standard
>> throw-catch scenario? Do I just check the Details property and handle
>> accordingly?

>
> The trick is that any unhandled exception thrown in your service will be
> turned into a SoapException with no details - except for a real
> SoapException. In that case, you can fill the Details property with
> whatever XML you need to tell the client what happened.


Thanks John, I've managed to sort this now by following your advice.

Kev


 
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
Does timer in Web Service Global.asax block my Web Service from processing web-site requests? Leo Violette ASP .Net Web Services 0 04-17-2009 12:39 AM
InvocationTargetException when calling "new Service()" in Axis web service to call another web service Michael Averstegge Java 0 01-10-2006 11:05 PM
Operation timed-out downloading web service durning Add Web Reference - still no solution Joe ASP .Net 4 10-31-2005 07:20 PM
Operation timed-out downloading web service durning Add Web Reference - still no solution Joe ASP .Net Web Services 2 10-31-2005 07:20 PM
Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class. DJ Dev ASP .Net 3 02-08-2004 04:19 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57