消费来自Delphi的oData服务 [英] Consume oData service from Delphi
本文介绍了消费来自Delphi的oData服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用来自Delphi的oData Web服务(我正在尝试与新的Bing Search Azure API进行交互)?在Delphi中几乎没有信息可以做到这一点.在这里此处,但它并没有太多帮助解释如何从Delphi的角度使用此类服务.谁能提供一个简单的例子?
How can I consume a oData webservice from Delphi (I'm trying to interact with the new Bing Search Azure API)? There is almost no information to do this in Delphi. There is a post here but it does not help much explaining how to consume such service from a Delphi point of view. Can anyone provide a simple example?
推荐答案
以下是使用netflix oData服务在Delphi XE中使用oData服务的非常简单的示例:
Here is a very simple example of consuming an oData service in Delphi XE using the netflix oData service:
program oDataDemo;
{$APPTYPE CONSOLE}
uses
SysUtils, msxml, Variants, Activex;
var
httpRequest: IXMLHttpRequest;
oDataServiceURI: String;
oDataFilter: String;
xmlResults: String;
begin
try
oDataServiceURI := 'http://odata.netflix.com/v2/Catalog/Titles()';
oDataFilter := '?$top=10';
coinitialize(nil);
httpRequest := CoXMLHTTP.Create;
httpRequest.open('GET', UTF8Encode(oDataServiceURI + oDataFilter), false, EmptyParam, EmptyParam);
httpRequest.send(EmptyParam);
xmlResults := httpRequest.responseText;
WriteLn(xmlResults);
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
这篇关于消费来自Delphi的oData服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文