| .NET DotNet Forum Index » ASP.NET - Webservices Forum » Managing webservice connections and/or sessions on... |
|
Page 1 of 1 |
|
| Author |
Message |
| Kursat... |
Posted: Tue Oct 13, 2009 8:49 am |
|
|
|
Guest
|
Hi,
I am employing a webservice in my C# application. I have generated proxy
class for the web service thus I instantiate an object from that class like
it is local, use it and let it garbage collected.
That is all for my side but I don't have any idea about what happens on the
server side. There will be an HTTP connection between client and server. Is
this connection automatically closed by the infrastructure when the
webservice proxy object is finalized? What about the Session on the server
side, when is it closed? Is there anything I should do explicitly with the
webservice proxy object to close http connection and session on server side?
Thanks in advance. |
|
|
| Back to top |
|
|
|
| Mr. Arnold... |
Posted: Tue Oct 13, 2009 2:02 pm |
|
|
|
Guest
|
"Kursat" <xx at (no spam) yy.com> wrote in message
news:O16GmRBTKHA.1236 at (no spam) TK2MSFTNGP05.phx.gbl...
Quote: Hi,
I am employing a webservice in my C# application. I have generated proxy
class for the web service thus I instantiate an object from that class
like it is local, use it and let it garbage collected.
That is all for my side but I don't have any idea about what happens on
the server side. There will be an HTTP connection between client and
server. Is this connection automatically closed by the infrastructure when
the webservice proxy object is finalized? What about the Session on the
server side, when is it closed? Is there anything I should do explicitly
with the webservice proxy object to close http connection and session on
server side?
You open the Web service connection from the client, and then it's the
client's responsibility to close the connection with a Dispose().
Web services are session less by default unless you have written code in the
Web service to keep session data.
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4504 (20091013) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com |
|
|
| Back to top |
|
|
|
| Kursat... |
Posted: Tue Oct 13, 2009 7:52 pm |
|
|
|
Guest
|
But the Web Service proxy class inherits non-virtual Dispose method from
"Component" class which doesn't know anything about connection closure.
Right?
"Mr. Arnold" <MR. Arnold at (no spam) Arnold.com> wrote in message
news:e9xxvAETKHA.508 at (no spam) TK2MSFTNGP06.phx.gbl...
Quote:
"Kursat" <xx at (no spam) yy.com> wrote in message
news:O16GmRBTKHA.1236 at (no spam) TK2MSFTNGP05.phx.gbl...
Hi,
I am employing a webservice in my C# application. I have generated proxy
class for the web service thus I instantiate an object from that class
like it is local, use it and let it garbage collected.
That is all for my side but I don't have any idea about what happens on
the server side. There will be an HTTP connection between client and
server. Is this connection automatically closed by the infrastructure
when the webservice proxy object is finalized? What about the Session on
the server side, when is it closed? Is there anything I should do
explicitly with the webservice proxy object to close http connection and
session on server side?
You open the Web service connection from the client, and then it's the
client's responsibility to close the connection with a Dispose().
Web services are session less by default unless you have written code in
the Web service to keep session data.
__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4504 (20091013) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
|
|
|
| Back to top |
|
|
|
| Mr. Arnold... |
Posted: Tue Oct 13, 2009 8:08 pm |
|
|
|
Guest
|
"Kursat" <xx at (no spam) yy.com> wrote in message
news:eWIJ2DHTKHA.3876 at (no spam) TK2MSFTNGP06.phx.gbl...
Quote: But the Web Service proxy class inherits non-virtual Dispose method from
"Component" class which doesn't know anything about connection closure.
Right?
I don't use proxy. However, the proxy class is on the client side, and it's
doing the Dispose() of the connection. It's the same thing. If you were not
using a proxy, then you are still responsible for the close of the
connection with a Dispose() at some point in your code that would not be
using a proxy.
If you don't Dispose() the Web service is some fashion in code, then the
Web server itself is going to close the connection on a timeout to release
resources, so the Web server can process other requests of other Web server
clients, and you don't want that.
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4504 (20091013) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com |
|
|
| Back to top |
|
|
|
| Kursat... |
Posted: Tue Oct 13, 2009 8:56 pm |
|
|
|
Guest
|
Hi Arnold,
Thanks for your help but I cant understand. I have a schema file for the web
service and I generated a proxy class by using wsdl.exe. My proxy class
doesn't have any method for connection closing. It just inherits a Dispose
method from "Component" class and I can't use the connection by using this
method. What should I do in this case? You said I am not using proxy class,
what do you for using web services?
Thanks
"Mr. Arnold" <MR. Arnold at (no spam) Arnold.com> wrote in message
news:uYhXENHTKHA.1732 at (no spam) TK2MSFTNGP02.phx.gbl...
Quote:
"Kursat" <xx at (no spam) yy.com> wrote in message
news:eWIJ2DHTKHA.3876 at (no spam) TK2MSFTNGP06.phx.gbl...
But the Web Service proxy class inherits non-virtual Dispose method from
"Component" class which doesn't know anything about connection closure.
Right?
I don't use proxy. However, the proxy class is on the client side, and
it's doing the Dispose() of the connection. It's the same thing. If you
were not using a proxy, then you are still responsible for the close of
the connection with a Dispose() at some point in your code that would not
be using a proxy.
If you don't Dispose() the Web service is some fashion in code, then the
Web server itself is going to close the connection on a timeout to release
resources, so the Web server can process other requests of other Web
server clients, and you don't want that.
__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4504 (20091013) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
|
|
|
| Back to top |
|
|
|
| Mr. Arnold... |
Posted: Tue Oct 13, 2009 9:52 pm |
|
|
|
Guest
|
"Kursat" <xx at (no spam) yy.com> wrote in message
news:%23zIjwnHTKHA.4780 at (no spam) TK2MSFTNGP05.phx.gbl...
Quote: Hi Arnold,
Thanks for your help but I cant understand. I have a schema file for the
web service and I generated a proxy class by using wsdl.exe. My proxy
class doesn't have any method for connection closing. It just inherits a
Dispose method from "Component" class and I can't use the connection by
using this method. What should I do in this case? You said I am not using
proxy class, what do you for using web services?
I don't use a proxy class created by wsdl.exe. I don't know what control
you have over the Web service or your client project, but you can set a Web
Service reference to the Web service over HTTP to a remote Web service
localhost or remote Web service over the Internet.
..NET will take care of everything so you don't have to use wsdl.exe '
generated class, if you use a Web reference in the client project.
http://msdn.microsoft.com/en-us/library/xb5th1ba(VS.80).aspx
I would still do a ws.Dispose() to kill the connection that's being shown to
you in the examples.
It's also being talked about 'Web Service Reference' in a client project on
page 240.
<http://books.google.com/books?id=YC1H0QkLPvsC&pg=PA234&lpg=PA234&dq=calling+a+web+method+from+c%23.net&source=bl&ots=O5XEjpoAlB&sig=_mxgvycVYEuluqCT_PelioVA3z4&hl=en&ei=QUXVSsbGHoaGtgeqz6CdAw&sa=X&oi=book_result&ct=result&resnum=6&ved=0CBsQ6AEwBQ#v=onepage&q=calling%20a%20web%20method%20from%20c%23.net&f=false>
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4504 (20091013) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com |
|
|
| Back to top |
|
|
|
| Kursat... |
Posted: Wed Oct 14, 2009 6:56 am |
|
|
|
Guest
|
I know using Web References and the book says generating proxy classes and
adding web references have same results. What I have will be a proxy class
over which I can call webmethods. But the problem is that the class doesn't
implement Dispose() method it just inherit it from the "Component" class
which is useless for connection closing. Does your class implement Dispose()
when you ass web reference? If yes can you send the implementation?
Thanks.
"Mr. Arnold" <MR. Arnold at (no spam) Arnold.com> wrote in message
news:u2qKKHITKHA.4324 at (no spam) TK2MSFTNGP05.phx.gbl...
|
|
|
| Back to top |
|
|
|
| Kursat... |
Posted: Wed Oct 14, 2009 7:19 am |
|
|
|
Guest
|
I added a web reference and it generated the same class. It just inherit
Dispose() from "Component" class.
"Kursat" <xx at (no spam) yy.com> wrote in message
news:ep$wO3MTKHA.1236 at (no spam) TK2MSFTNGP05.phx.gbl...
Quote: I know using Web References and the book says generating proxy classes and
adding web references have same results. What I have will be a proxy class
over which I can call webmethods. But the problem is that the class doesn't
implement Dispose() method it just inherit it from the "Component" class
which is useless for connection closing. Does your class implement
Dispose() when you ass web reference? If yes can you send the
implementation?
Thanks.
"Mr. Arnold" <MR. Arnold at (no spam) Arnold.com> wrote in message
news:u2qKKHITKHA.4324 at (no spam) TK2MSFTNGP05.phx.gbl...
"Kursat" <xx at (no spam) yy.com> wrote in message
news:%23zIjwnHTKHA.4780 at (no spam) TK2MSFTNGP05.phx.gbl...
Hi Arnold,
Thanks for your help but I cant understand. I have a schema file for the
web service and I generated a proxy class by using wsdl.exe. My proxy
class doesn't have any method for connection closing. It just inherits a
Dispose method from "Component" class and I can't use the connection by
using this method. What should I do in this case? You said I am not
using proxy class, what do you for using web services?
I don't use a proxy class created by wsdl.exe. I don't know what control
you have over the Web service or your client project, but you can set a
Web Service reference to the Web service over HTTP to a remote Web
service localhost or remote Web service over the Internet.
.NET will take care of everything so you don't have to use wsdl.exe '
generated class, if you use a Web reference in the client project.
http://msdn.microsoft.com/en-us/library/xb5th1ba(VS.80).aspx
I would still do a ws.Dispose() to kill the connection that's being shown
to you in the examples.
It's also being talked about 'Web Service Reference' in a client project
on page 240.
http://books.google.com/books?id=YC1H0QkLPvsC&pg=PA234&lpg=PA234&dq=calling+a+web+method+from+c%23.net&source=bl&ots=O5XEjpoAlB&sig=_mxgvycVYEuluqCT_PelioVA3z4&hl=en&ei=QUXVSsbGHoaGtgeqz6CdAw&sa=X&oi=book_result&ct=result&resnum=6&ved=0CBsQ6AEwBQ#v=onepage&q=calling%20a%20web%20method%20from%20c%23.net&f=false
__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4504 (20091013) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
|
|
|
| Back to top |
|
|
|
| Mr. Arnold... |
Posted: Wed Oct 14, 2009 8:40 am |
|
|
|
Guest
|
Kursat wrote:
Quote: I added a web reference and it generated the same class. It just inherit
Dispose() from "Component" class.
I don't know what the deal is with Dispose() for you. If you Dispose()
of the object it's being destroyed. If the object itself is being
destroyed, then all resources the object is using are released. I don't
care if the object is inheriting from base object. The object is being
destroyed. If you don't want to do the Dispose(), then set the object to
a null value and destroy it.
The bottom line is if the object is destroyed, the object is no longer
holding resources. If the object happens to be a Web service object that
has been instantiated on the client side, then destroy the object and
release all resources the object is using.
It doesn't get any simpler than that. If you need more information about
this, then may I suggest you use Bing or Google and look it up.
HTH
good luck to you |
|
|
| Back to top |
|
|
|
| milop... |
Posted: Fri Oct 16, 2009 2:23 pm |
|
|
|
Guest
|
Just use "using":
using (MyWebService ws = new MyWebService())
{
ws.DoSomething();
}
At this point the webservice instance has been disposed of.
"Kursat" <xx at (no spam) yy.com> wrote in message
news:Oi0LKENTKHA.4360 at (no spam) TK2MSFTNGP04.phx.gbl...
Quote: I added a web reference and it generated the same class. It just inherit
Dispose() from "Component" class.
"Kursat" <xx at (no spam) yy.com> wrote in message
news:ep$wO3MTKHA.1236 at (no spam) TK2MSFTNGP05.phx.gbl...
I know using Web References and the book says generating proxy classes and
adding web references have same results. What I have will be a proxy class
over which I can call webmethods. But the problem is that the class
doesn't implement Dispose() method it just inherit it from the "Component"
class which is useless for connection closing. Does your class implement
Dispose() when you ass web reference? If yes can you send the
implementation?
Thanks.
"Mr. Arnold" <MR. Arnold at (no spam) Arnold.com> wrote in message
news:u2qKKHITKHA.4324 at (no spam) TK2MSFTNGP05.phx.gbl...
"Kursat" <xx at (no spam) yy.com> wrote in message
news:%23zIjwnHTKHA.4780 at (no spam) TK2MSFTNGP05.phx.gbl...
Hi Arnold,
Thanks for your help but I cant understand. I have a schema file for
the web service and I generated a proxy class by using wsdl.exe. My
proxy class doesn't have any method for connection closing. It just
inherits a Dispose method from "Component" class and I can't use the
connection by using this method. What should I do in this case? You
said I am not using proxy class, what do you for using web services?
I don't use a proxy class created by wsdl.exe. I don't know what
control you have over the Web service or your client project, but you
can set a Web Service reference to the Web service over HTTP to a remote
Web service localhost or remote Web service over the Internet.
.NET will take care of everything so you don't have to use wsdl.exe '
generated class, if you use a Web reference in the client project.
http://msdn.microsoft.com/en-us/library/xb5th1ba(VS.80).aspx
I would still do a ws.Dispose() to kill the connection that's being
shown to you in the examples.
It's also being talked about 'Web Service Reference' in a client project
on page 240.
http://books.google.com/books?id=YC1H0QkLPvsC&pg=PA234&lpg=PA234&dq=calling+a+web+method+from+c%23.net&source=bl&ots=O5XEjpoAlB&sig=_mxgvycVYEuluqCT_PelioVA3z4&hl=en&ei=QUXVSsbGHoaGtgeqz6CdAw&sa=X&oi=book_result&ct=result&resnum=6&ved=0CBsQ6AEwBQ#v=onepage&q=calling%20a%20web%20method%20from%20c%23.net&f=false
__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4504 (20091013) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
|
|
|
| Back to top |
|
|
|
| Mr. Arnold... |
Posted: Fri Oct 16, 2009 5:30 pm |
|
|
|
Guest
|
"milop" <milop at (no spam) slomins.com> wrote in message
news:eKY$k6pTKHA.220 at (no spam) TK2MSFTNGP02.phx.gbl...
Quote: Just use "using":
using (MyWebService ws = new MyWebService())
{
ws.DoSomething();
}
At this point the webservice instance has been disposed of.
The above is not a good practice, and as a matter of fact, when using a WCF
Web service, there is documentation that specifically indicates not to use
the Using statement on client connection to the WCF Web service.
http://www.devx.com/dotnet/Article/39023
WCF Webservice
var ws = new Webservice();
ws.DoSomething;
ws.Close();
legacy Webservice
var ws = new Webservice();
ws.DoSomething;
ws.Dispose();
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4516 (20091016) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com |
|
|
| Back to top |
|
|
|
| milop... |
Posted: Fri Oct 16, 2009 6:10 pm |
|
|
|
Guest
|
Well, the bottom line is proper class design, knowledge of managed and
unmanged resources and garbage collection, and disciplined programming
practices.
Although, spcifically calling Dispose() on an object doesn't hurt. Hell, I
even erase arrays when they're no longer going to be used. I don't want to
wait for the GC (I have a C++ background )
"Mr. Arnold" <MR. Arnold at (no spam) Arnold.com> wrote in message
news:uryMyirTKHA.508 at (no spam) TK2MSFTNGP06.phx.gbl...
Quote:
"milop" <milop at (no spam) slomins.com> wrote in message
news:eKY$k6pTKHA.220 at (no spam) TK2MSFTNGP02.phx.gbl...
Just use "using":
using (MyWebService ws = new MyWebService())
{
ws.DoSomething();
}
At this point the webservice instance has been disposed of.
The above is not a good practice, and as a matter of fact, when using a
WCF Web service, there is documentation that specifically indicates not to
use the Using statement on client connection to the WCF Web service.
http://www.devx.com/dotnet/Article/39023
WCF Webservice
var ws = new Webservice();
ws.DoSomething;
ws.Close();
legacy Webservice
var ws = new Webservice();
ws.DoSomething;
ws.Dispose();
__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4516 (20091016) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
|
|
|
| Back to top |
|
|
|
|