
June 4th, 2004, 07:36 AM
|
|
Registered User
|
|
Join Date: Apr 2004
Posts: 12
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
XML problems
I am building a CGI program in Delphi that connects to a financial service to retrieve some stock data using SOAP and WSDL binding. Hence in my I want my CGI program to reference an imported WSDL file called xQuotes.
I am getting back an Array of Quote from the website which I have assigned to stockArray of the same datatype. But when I try to process the request to generate a XML document I get an error message reading the following:
[Error] GlobalStockService.pas(83): There is no overloaded version of 'LoadFromXML' that can be called with these arguments
The code is provided below:
//My CGI program
procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
i: integer;
//declare stock data
//DOMString : wideString;
Name, Symbol, Date, Time, result :wideString;
Last, Open, High_, Low_ :double;
//declare Array of Qutotes
stockArray: ArrayOfQuote;
//Declare a list of XML elements
nodeList: IXMLNodeList;
//Get individual XML elements
node1, node2, node3, node4 : IXMLNode;
found :boolean;
auth: Header;
begin
//code goes here
found := false;
i := 0;
name := 'MSFT'; //change MSFT to something more dynamic
symbol := 'AUD'; //change AUD to soemthing more dynamic
//load from XML schema, should maybe be XMLDocument3 instead of XMLDocument1
//create tree level structure
XMLDocument1.LoadFromXML('<?xml version="1.0"?>' +#10+'<stock>' +#10+'</stock>');
//call getQuotes webservice from xignite.com
//Change MSFT to something more dynamic
stockArray := (HTTPRIO1 as XigniteQuotesSOAP).getQuotes('MSFT');
//read contents from arrayOfQuote into stockArray
Name := stockArray[0].Name;
Symbol := stockArray[1].Symbol;
Date := stockArray[2].Date;
Time := stockArray[3].Time;
Last := stockArray[4].Last;
Open := stockArray[5].Open;
High_ := stockArray[6].High_;
Low_ := stockArray[7].Low_;
//check that the stockArray contains data
if not (stockArray[0].Name = 'Data not found') then
begin
XMLDocument1.LoadFromXML(stockArray);
node3 := XMLDocument1.DocumentElement.CloneNode(true);
//XMLDocument3.DocumentElement.ChildNodes.Add(node3);
end;
//include code from lines 24-45 from airport code example
//From Line 46-49
XMLDocument2.SaveToXML(result);
response.ContentType := 'text/xml';
response.Content := FormatXMLData(result);
end;
end.
//Imported WSDL file
unit xQuotes;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
type
// ************************************************************************ //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// to but never[!] declared in the document. The types from the latter category
// typically map to predefined/known XML or Borland types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:string - "http://www.w3.org/2001/XMLSchema"
// !:double - "http://www.w3.org/2001/XMLSchema"
// !:int - "http://www.w3.org/2001/XMLSchema"
// !:dateTime - "http://www.w3.org/2001/XMLSchema"
Header = class; { "http://www.xignite.com/services/"[H] }
Common = class; { "http://www.xignite.com/services/" }
QuickQuote = class; { "http://www.xignite.com/services/" }
HTMLResult = class; { "http://www.xignite.com/services/" }
HistoricalQuote = class; { "http://www.xignite.com/services/" }
Quote = class; { "http://www.xignite.com/services/" }
StockQuote = class; { "http://www.xignite.com/services/" }
StockStatistics = class; { "http://www.xignite.com/services/" }
StockNews = class; { "http://www.xignite.com/services/" }
ExtendedQuote = class; { "http://www.xignite.com/services/" }
FundQuote = class; { "http://www.xignite.com/services/" }
ExtendedFundQuote = class; { "http://www.xignite.com/services/" }
Index = class; { "http://www.xignite.com/services/" }
Indicator = class; { "http://www.xignite.com/services/" }
MarketSummary = class; { "http://www.xignite.com/services/" }
Top = class; { "http://www.xignite.com/services/" }
MarketIndex = class; { "http://www.xignite.com/services/" }
{ "http://www.xignite.com/services/" }
OutcomeTypes = (Success, SystemError, RequestError, RegistrationError);
Quote = class(Common)
private
FSymbol: WideString;
FName: WideString;
FDate: WideString;
FTime: WideString;
FOpen: Double;
FHigh_: Double;
FLow_: Double;
FLast: Double;
FVolume: Double;
FChange: Double;
FPercentChange: Double;
FPrevious_Close: WideString;
FBid: WideString;
FBid_Size: WideString;
FAsk: WideString;
FAsk_Size: WideString;
FHigh_52_Weeks: WideString;
FLow_52_Weeks: WideString;
published
property Symbol: WideString read FSymbol write FSymbol;
property Name: WideString read FName write FName;
property Date: WideString read FDate write FDate;
property Time: WideString read FTime write FTime;
property Open: Double read FOpen write FOpen;
property High_: Double read FHigh_ write FHigh_;
property Low_: Double read FLow_ write FLow_;
property Last: Double read FLast write FLast;
property Volume: Double read FVolume write FVolume;
property Change: Double read FChange write FChange;
property PercentChange: Double read FPercentChange write FPercentChange;
property Previous_Close: WideString read FPrevious_Close write FPrevious_Close;
property Bid: WideString read FBid write FBid;
property Bid_Size: WideString read FBid_Size write FBid_Size;
property Ask: WideString read FAsk write FAsk;
property Ask_Size: WideString read FAsk_Size write FAsk_Size;
property High_52_Weeks: WideString read FHigh_52_Weeks write FHigh_52_Weeks;
property Low_52_Weeks: WideString read FLow_52_Weeks write FLow_52_Weeks;
end;
ArrayOfQuote = array of Quote; { "http://www.xignite.com/services/" }
end.
Any help would be much appreciated !!!
|