using System;
using System.Net;
namespace MyApplication
{
public class MyFixedHTTPService : MyService
{
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest w = base.GetWebRequest(uri) as HttpWebRequest;
w.ProtocolVersion = HttpVersion.Version10;
return w;
}
}
}and then use this class to call your service. This forces the proxy to use HTTP 1.0. The best thing about the subclassing approach is that you can simply regenerate the proxy class if you need to, while still retaining your modifications
Motto: "Talk is cheap, show me the code!"
This blog attempts to be a collection of how-to examples in the Microsoft software stack - things that may take forever to find out, especially for the beginner. I see it as my way to return something to the Microsoft community in exchange for what I learned from it.
Showing posts with label HTTP version. Show all posts
Showing posts with label HTTP version. Show all posts
28 February 2008
Forcing a web service proxy to use a specific http version
A short one this time, and a rare one too, but taken from real life. Sometimes a web service is implemented in such a way that it only understands http 1.1 or 1.0 but the proxy class that Visual Studio.NET generated does not know that (because the service is badly implemented, or for some other reason). If you cannot change the service implementation, you will have to change your client implementation.
Say, you added a web reference to a web service and called the generated proxy class "MyService".
The only thing you need to do is:
Geplaatst door
Joost van Schaik
op
Thursday, February 28, 2008
Labels:
ASP.NET,
C#,
HTTP,
HTTP version,
Proxy,
Web Services
Subscribe to:
Posts (Atom)
