Consuming NOAA and Avoiding Protocol Violation in .Net
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.
Alternatively you may be able to add the following to your app.config:
This way, if the NOA site stops having a protocol violation you don’t have to recompile your app.
Alternatively you may be able to add the following to your app.config:
This way, if the NOA site stops having a protocol violation you don’t have to recompile your app.
it appears that this blog cannot handle html comments
abc
Where is the “generated reference.cs” file? All I can see in VS is a .discomap and a .wsdl file. (I’m learning VS2005 right now)
I have written a blog entitled Where are the Hidden Files using Visual Studio 2005?