简体   繁体   English

国家气象服务网络服务的空响应

[英]Empty response from National Weather Service web service

I wrote a process that retrieved data from the National Weather Service web service. 我编写了一个从National Weather Service Web服务检索数据的过程。 It was working nicely for several years until Valentines Day. 直到情人节,它一直运行良好。 Now the call keeps getting an empty response error. 现在,该呼叫不断收到一个空的响应错误。 I've contacted the National Weather Service and they so far have not been able to provide any suggestions except to say they recently changed to https. 我已经与国家气象局联系,到目前为止,他们无法提供任何建议,只是说他们最近更改为https。 I tried creating a new simple test project with a new reference to their https URL and I still get the empty response error. 我尝试使用对其https URL的新引用创建一个新的简单测试项目,但仍然出现空响应错误。 Can anyone suggest a solution? 谁能提出解决方案?

I set a web reference to: 我将网络参考设置为:

https://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl https://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl

Here's the code I am testing and it still fails with the empty response error: 这是我正在测试的代码,它仍然失败,并显示空响应错误:

    private void cmdGo_Click(object sender, RoutedEventArgs e)
    {
        decimal nLatitude = (decimal)30.32;
        decimal nLongitude = (decimal)-81.55;
        DateTime dEndTime = DateTime.Now;
        DateTime dStartTime = dEndTime.AddHours(-2);
        XmlDocument oXmlDocument = GetXmlDocument(nLatitude, nLongitude, dStartTime, dEndTime);
    }
    private XmlDocument GetXmlDocument(decimal nLatitude, decimal nLongitude, DateTime dStartTime, DateTime dEndTime)
    {
        XmlDocument oXmlDocument = new XmlDocument();
        try
        {
            gov.weather.graphical.ndfdXML oWebProxy = new gov.weather.graphical.ndfdXML();
            gov.weather.graphical.productType oProductType = gov.weather.graphical.productType.timeseries;
            gov.weather.graphical.unitType oUnitType = gov.weather.graphical.unitType.e;
            gov.weather.graphical.weatherParametersType oWeatherParametersType = new gov.weather.graphical.weatherParametersType();
            oWeatherParametersType.appt = true;         // Apparent Temperature
            oWeatherParametersType.icons = true;        // Conditions Icons
            oWeatherParametersType.dew = true;          // Dew Point Temperature
            oWeatherParametersType.maxt = true;         // Daily Maximum Temperature
            oWeatherParametersType.mint = true;         // Daily Minimum Temperature - no response
            oWeatherParametersType.pop12 = true;        // 12 Hourly Probability of Precipitation
            oWeatherParametersType.precipa_r = true;    // Liquid Precipitation Amount
            oWeatherParametersType.rh = true;           // Relative Humidity
            oWeatherParametersType.sky = true;          // Cloud Cover Amount
            oWeatherParametersType.snow = true;         // Snow Amount
            oWeatherParametersType.temp = true;         // Temperature
            oWeatherParametersType.wdir = true;         // Wind Direction
            oWeatherParametersType.wgust = true;        // Wind Speed Gust
            oWeatherParametersType.wspd = true;         // Wind Speed
            oWeatherParametersType.wwa = true;          // Watches, Warnings, and Advisories
            oWeatherParametersType.wx = true;           // Weather Type, Coverage, and Intensity

            string sXmlData = oWebProxy.NDFDgen(nLatitude, nLongitude, oProductType, dStartTime, dEndTime, oUnitType, oWeatherParametersType);
            oXmlDocument.LoadXml(sXmlData);
        }
        catch (Exception e)
        {
            string sMessage = e.Message;
            sMessage = "Error: " + sMessage;
        }
        return oXmlDocument;
    }

For the c# web reference I changed ours from: 对于C#Web参考,我将以下内容更改为:

http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl

to: 至:

https://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php?wsdl https://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php?wsdl

I had to change a few of the parameters for my call to "string" format but the xml it returned seemed to be in the same format as the other url I used. 我必须将一些参数更改为“字符串”格式,但返回的xml似乎与我使用的其他url格式相同。

Hope this helps. 希望这可以帮助。

My call is now: 我的电话现在是:

ndfdXML.NDFDgenByDay(currentLoc.latitude, currentLoc.longitude, DateTime.Now, "7", "e", "12 hourly");

To get the 7 day in my area. 得到我所在地区的7天。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM