我编写了一个从国家气象服务网络服务中检索数据的流程。直到情人节,这几年都很好用。现在,调用不断获得空响应错误。我已联系国家气象局,他们到目前为止还没有提供任何建议,只是说他们最近改为https。我尝试使用对其https URL的新引用创建一个新的简单测试项目,但仍然得到空响应错误。有人可以提出解决方案吗?
我将网络引用设置为:
https://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl
这是我正在测试的代码,它仍然会因空响应错误而失败:
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;
}
答案 0 :(得分:4)
对于c#web引用,我将其改为:
http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl
为:
https://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php?wsdl
我必须将我调用的一些参数更改为“string”格式,但它返回的xml似乎与我使用的其他URL的格式相同。
希望这有帮助。
我的电话现在是:
ndfdXML.NDFDgenByDay(currentLoc.latitude, currentLoc.longitude, DateTime.Now, "7", "e", "12 hourly");
在我所在地区获得7天。