multiple webservice calls in one persistent connection

K

kplkumar

Hi

I want to make calls to my webservice method multiple times using a
persistent http connection. Is this possible?
 
J

John Saunders [MVP]

kplkumar said:
Hi

I want to make calls to my webservice method multiple times using a
persistent http connection. Is this possible?

This can't be done without great effort. Are you sure you need to control
things in this level of detail?
 
K

kplkumar

Yeah, I want to do this. I know internet browsers do this, by using
KeepAlive, however I don't know how it could be done from a windows
application calling a webservice.

Can you tell me how??
 
K

kplkumar

Yeah, I want to do this. I know internet browsers do this, by using
KeepAlive, however I don't know how it could be done from a windows
application calling a webservice.

In other words, I want to have a persistent connection with the server
and make multiple websrevice calls (requests) and close the
connection.

Can you tell me how??
 
J

John Saunders [MVP]

kplkumar said:
Yeah, I want to do this. I know internet browsers do this, by using
KeepAlive, however I don't know how it could be done from a windows
application calling a webservice.

In other words, I want to have a persistent connection with the server
and make multiple websrevice calls (requests) and close the
connection.

Can you tell me how??

It's very difficult, it it's possible at all. Internet browsers do it
because they are in complete control of their interaction with the server.
If you want to do the same, you'll either have to do a bunch of very
sophisticated programming (have you ever written code that generates code?),
or you'll have to perform the interaction with the server yourself, and do
without the conveniences that Microsoft offers you.

In particular, you can create your own subclass of
System.Web.Services.Protocols.SoapHttpClientProtocol. You'll have to
override the GetWebRequest method to return an instance of HttpWebRequest
with the KeepAlive property set to true.

But your proxy classes will have to derive from your new subclass. This
means that you won't be able to use Add Web Reference or WSDL.EXE to create
your proxy classes.

Unless, that is, you write a SoapProtocolImporter which will generate proxy
classes based on your own subclass instead of the default
SoapHttpClientProtocol.

I've never done these things, since they are too complicated for most
purposes. It's always been better to let .NET decide whether or not to keep
a connection open, rather than worrying about it myself. Certainly, if you
have determined that there's either a measurable performance impact, or if
you need to do it in order to interact with a server which requires it, then
you have to do it.

And good luck to you. If it works, you should publish the solution.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top