使用异步方法调用Xignite

本文关键字:Xignite 调用 异步方法 | 更新日期: 2023-09-27 18:01:09

嗨,我有以下代码,正在尝试调用xignite中的一些历史数据。在这种情况下,xyz库是xignite库。

 //fire an event GetHistoricalQuotesAsOfCompleted
                proxy.GetHistoricalQuotesAsOfCompleted +=
                    new EventHandler<GetHistoricalQuotesAsOfCompletedEventArgs>(GetHistoricalQuotesAsOfCompleted);
                //asynchronously request quotes for a time period
                proxy.GetHistoricalQuotesAsOfAsync(ticker, xyz.IdentifierTypes.Symbol,
                    DateTime.Now.ToString(), PeriodTypes.Day, days);

这是我在IE浏览器中得到的错误

Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB6; EasyBits GO v1.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.21022; .NET CLR 3.5.30729; MDDR; InfoPath.2; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)
Timestamp: Wed, 6 Jul 2011 02:50:12 UTC

Message: Unhandled Error in Silverlight Application Object reference not set to an instance of an object.   at newAmStockChart.MainPage.GetHistoricalQuotesAsOfCompleted(Object sender, GetHistoricalQuotesAsOfCompletedEventArgs e)
   at newAmStockChart.xyz.XigniteHistoricalSoapClient.OnGetHistoricalQuotesAsOfCompleted(Object state)
Line: 1
Char: 1
Code: 0
URI: http://localhost:60260/newAmStockChartTestPage.aspx

Message: Unhandled Error in Silverlight Application Object reference not set to an instance of an object.   at newAmStockChart.MainPage.GetHistoricalQuotesAsOfCompleted(Object sender, GetHistoricalQuotesAsOfCompletedEventArgs e)
   at newAmStockChart.xyz.XigniteHistoricalSoapClient.OnGetHistoricalQuotesAsOfCompleted(Object state)
Line: 1
Char: 1
Code: 0
URI: http://localhost:60260/newAmStockChartTestPage.aspx

使用异步方法调用Xignite

我发现最好的方法不是通过SOAP,而是在后端使用REST,然后解析返回的JSON。

以下是REST调用的Xignite URL示例,类似于返回JSON:的原始问题

http://www.xignite.com/xGlobalHistorical.json/GetGlobalHistoricalQuotesAsOf?Identifier=GOOG&IdentifierType=符号&AdjustmentMethod=SplitOnly&结束日期=2/3/2014&PeriodType=天&周期=7

如果您想要XML或CSV,只需在上面的URL中替换".XML"或".CSV"即可。