I need to get some data from a service provider and configure our .net application to point to their hosted web service in order to receive the data. Using the following code when the web method ( ws.DoTransfer ) is ws.DoTransfer , I get the following error ...
private void DoTransferLocal() { Version version = new Version(); string error = string.Empty; try { RemoteService ws = new RemoteService(); ServicePoint spm = ServicePointManager.FindServicePoint(new Uri(ws.Url)); spm.Expect100Continue = true; version = spm.ProtocolVersion; ws.Credentials = credentials; ws.PreAuthenticate = true; RemoteResult result = ws.DoTransfer(); MessageBox.Show("Result = " + result.transferStatus); } catch (Exception ex) { error = ex.Message; } finally { MessageBox.Show(version.ToString() + Environment.NewLine + error); } }
Error:
Request failed with HTTP status 505: HTTP version is not supported.
I was told that the HTTP version should be 1.0, but my version 1.1
I read a couple of google posts about this and saw suggestions to override the GetWebRequest method, as shown here ...
protected override System.Net.WebRequest GetWebRequest(Uri uri) { System.Net.HttpWebRequest request = base.GetWebRequest(uri) as System.Net.HttpWebRequest; request.ProtocolVersion = System.Net.HttpVersion.Version10; return request; }
... but when I try this, GetWebRequest after base. it is underlined in red and has an error ...
"Object" does not contain a definition for "GetWebRequest"
Can someone tell me how I change the version of HTTP to 1.0, but still use the same code (rather than building up my own packages with soap) to call my web method?
I can not find any code that I can just enter into my code that looks like the following line ...
ws.HttpVersion = HttpVersion.Version10;
thanks
source share