tag:blogger.com,1999:blog-5295746446529817470.post1217099758309491759..comments2023-05-09T16:29:24.130+02:00Comments on Dotnet by Example: Forcing a web service proxy to use a specific http versionJoost van Schaikhttp://www.blogger.com/profile/02182444268071162776noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-5295746446529817470.post-3369950041635221332009-02-23T05:43:00.000+01:002009-02-23T05:43:00.000+01:00Hello Joost,Few updates:I created sample applicati...Hello Joost,<BR/><BR/>Few updates:<BR/><BR/>I created sample application which GETs google logo through HTTP web request in first place and then call one sample asp.net web-service through HTTP POST method. Surprisingly, in Fiddler, I found Google page not found error-page for the second asp.net web-service call. And vice versa, if asp.net web-service is called in first place, I got asp.net page not found error-page for the google logo request. i.e. first good connection was used for consecutive web calls in the same application life cycle.<BR/><BR/>Reason:<BR/>The default ‘Keep Alive’ in web-service call or in HTTP web request (that we do for file downloads) is true, meaning the same TCP connection will be used for all requests be it web-service or HTTP calls.<BR/><BR/>Fix:<BR/>In order to fix the problem, we must have to set Keep-Alive property to FALSE explicitly for both HTTP and Web-service calls. However there is a possibility of performance hit.<BR/><BR/>Trick for Web-service calls:<BR/>We may never want to call web-service through raw HTTP web requests. But web-service proxy class which is created through .NET IDE doesn't expose http web request object. Anyways, you can write a partial class extending .NET IDE generated class and override onGetRequest and assign Keep Alive to false.<BR/><BR/>It works. Thank you for your co operation so far.<BR/><BR/>Thanks!<BR/>DhananjayDhananjayhttps://www.blogger.com/profile/15183171539153925231noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-27903307820569813502009-02-21T14:37:00.000+01:002009-02-21T14:37:00.000+01:00Hello Dhananjay I have looked into your code and w...Hello Dhananjay<BR/> <BR/>I have looked into your code and while I fail to see what you are trying to accomplish, I can one thing for sure: you set a proxy for your plain HTTP request, but you fail to do so for your web service call. I have changed the code of your CallWebService2 method using a little copy-and-past from your own code<BR/> <BR/>private void CallWebService2()<BR/>{<BR/> bool bAuto = chkAuto.Checked;<BR/> string strIP = txtIP.Text;<BR/> string strPort = txtPort.Text;<BR/> string strUser = txtUser.Text;<BR/> string strPass = txtPass.Text;<BR/><BR/> SampleWebService.SimpleWebService service = new ProxyCheck.SampleWebService.SimpleWebService();<BR/> if (bAuto == false)<BR/> {<BR/> //use user provided proxy settings<BR/> service.Proxy = new WebProxy(strIP, Convert.ToInt16(strPort));<BR/> service.Credentials = new NetworkCredential(strUser, strPass);<BR/> }<BR/> string result = service.EchoInput("Hello World!");<BR/> WriteToTextbox("Result: " + result);<BR/>}<BR/><BR/>and now it seems to work fine. Nice program that AnalogX Proxy btw. Might come in handy one day<BR/> <BR/>Cheers, JoostJoost van Schaikhttps://www.blogger.com/profile/02182444268071162776noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-56897078812581648092009-02-17T11:41:00.000+01:002009-02-17T11:41:00.000+01:00Hi,I am facing little problem and think you would ...Hi,<BR/>I am facing little problem and think you would be capable to answer it.<BR/><BR/>The environment contains, web-service hosted on internet, a proxy server and a client machine which needs to connect first to proxy to hit the web service.<BR/><BR/>In one of my sample application, I have to call the webservice first and then require to download a file from internet, both on different servers.<BR/><BR/>Proxy information is set on IE and I do nothing programatically as far as proxy settings are concerned.<BR/><BR/>Its strange to see that I am able to hit the web service but could not download the file. I use standard HttpWebRequest and HttpResponse classes for file download.<BR/><BR/>The error message I receive is: The remote server returned an error: (404) Not Found. at System.Net.HttpWebRequest.GetResponse()<BR/><BR/>I tried running different web-services but I observe same behaviour. However If I call the download method first, it runs without any error.<BR/><BR/>I would appreciate any help.<BR/><BR/>Thanks!<BR/>dgoyani@gmail.comDhananjayhttps://www.blogger.com/profile/15183171539153925231noreply@blogger.com