来自国家气象局 Web 服务的空响应 [英] Empty response from National Weather Service web service

查看:79
本文介绍了来自国家气象局 Web 服务的空响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个从国家气象局 Web 服务中检索数据的过程.它在情人节之前一直运行良好.现在调用不断收到空响应错误.我已经联系了国家气象局,他们到目前为止还没有提供任何建议,只是说他们最近更改了 https.我尝试使用对其 https URL 的新引用创建一个新的简单测试项目,但我仍然收到空响应错误.任何人都可以提出解决方案吗?

I wrote a process that retrieved data from the National Weather Service web service. 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. I tried creating a new simple test project with a new reference to their https URL and I still get the empty response error. Can anyone suggest a solution?

我将网络引用设置为:

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;
    }

推荐答案

对于 c# 网络参考,我将我们的从:

For the c# web reference I changed ours from:

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

到:

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

我不得不将一些参数更改为字符串"格式,但它返回的 xml 似乎与我使用的其他 url 的格式相同.

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.

希望这会有所帮助.

我的电话现在是:

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

在我所在的地区获得 7 天.

To get the 7 day in my area.

这篇关于来自国家气象局 Web 服务的空响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆