Results 1 to 2 of 2

Thread: [2005] Problem Consuming SOAP Web Service in my VB app

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    [2005] Problem Consuming SOAP Web Service in my VB app

    I am trying to use this NOAA webservice in my VB 2005 application.

    http://www.nws.noaa.gov/forecasts/xml/

    I am using this server function

    You can view an example of how to invoke NDFDgenByDay() in the following web page and the SOAP client it uses.

    http://www.weather.gov/forecasts/xml...dSOAPByDay.htm

    And my code looks like this:
    VB Code:
    1. Try
    2.             Dim decLat As Decimal = CDec(38.99)
    3.             Dim decLon As Decimal = CDec(-77.99)
    4.             Dim dtDate As Date = CDate("2006-06-28")
    5.             Dim strDays As String = "5"
    6.  
    7.  
    8.             Dim myWebService As New gov.weather.[url]www.ndfdXML[/url]
    9.  
    10.             myWebService.NDFDgenByDay( _
    11.                 decLat, _
    12.                 decLon, _
    13.                 dtDate, _
    14.                 strDays, _
    15.                 gov.weather.[url]www.formatType.Item12hourly[/url])
    16.  
    17.         Catch ex As Exception
    18.             MessageBox.Show( _
    19.                 ex.Message & vbNewLine & _
    20.                 ex.Source & vbNewLine & _
    21.                 ex.StackTrace, _
    22.                 "Web Service Error", _
    23.                 MessageBoxButtons.OK, _
    24.                 MessageBoxIcon.Error)
    25.         End Try

    I am getting this error:

    ---------------------------
    Web Service Error
    ---------------------------
    The server committed a protocol violation. Section=ResponseStatusLine

    System.Web.Services

    at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)

    at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)

    at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

    at NOAA_Weather.gov.weather.www.ndfdXML.NDFDgenByDay(Decimal latitude, Decimal longitude, DateTime startDate, String numDays, formatType format) in C:\NOAA\NOAA_Weather\NOAA_Weather\Web References\gov.weather.www\Reference.vb:line 112

    at NOAA_Weather.Form1.btnGetWeather_Click(Object sender, EventArgs e) in C:\NOAA\NOAA_Weather\NOAA_Weather\Form1.vb:line 13

    Anybody see anything that obviously wrong.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    RE: [2005] Problem Consuming SOAP Web Service in my VB app

    Fixed with the help of this link. Basicaly you need to force HTTP/1.0 protocol which prevents the server from using chunked encoding.

    The VB Code to do so is
    VB Code:
    1. Protected Overrides Function GetWebRequest(ByVal uri As Uri) As WebRequest
    2.             'Quick & Dirty NOAA Weather hack added to the wsdl generated file
    3.             Dim request As HttpWebRequest = CType(MyBase.GetWebRequest(uri), HttpWebRequest)
    4.             request.ProtocolVersion = HttpVersion.Version10
    5.             Return request
    6.         End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width