In .Net 2/3 one can consume the NOAA web service WSDL at (http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl) and run into this error

Exception: System.Net.WebException
Message: The server committed a protocol violation. Section=ResponseStatusLine
Source: System.Web.Services
TargetSite: System.Net.WebResponse GetWebResponse(System.Net.WebRequest)

  To get around this issue open up the generated reference.cs file and add this to the web service proxy class and rebuild and run

protected override WebRequest GetWebRequest(Uri uri)
{
    HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri);
    request.ProtocolVersion = HttpVersion.Version10;
    return request;
}

Thanks goes to Rob Garret’s blog on this.

Share