Hi ,
I am using delphi6 and trying to use google api's web services,
but I always get the error "Internal server Error(500"

this is my code


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, 
Forms,
  Dialogs, Rio, SoapHTTPClient, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    HTTPRIO1: THTTPRIO;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
uses unit2,unit3;
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  r      : string;
begin
  r:=(HTTPRIO1 as 
GoogleSearchPort).doSpellingSuggestion('abcdefghijklmn',edit1.text);
end;

end.




Unit Unit3;

interface

uses Types, XSBuiltIns, Unit2;
type

  GoogleSearchPort = interface(IInvokable)
    ['{98AEEBAE-78F3-4564-8E0D-B18DB2B8F373}']
    function doGetCachedPage(const key: WideString; const url: 
WideString): TByteDynArray;  stdcall;
    function doSpellingSuggestion(const key: WideString; const phrase: 
WideString): WideString;  stdcall;
    function doGoogleSearch(const key: WideString; const q: WideString; 
const start: Integer; const maxResults: Integer; const filter: Boolean; 
const restrict: WideString; const safeSearch: Boolean; const lr: 
WideString; const ie: WideString; const oe: WideString): 
GoogleSearchResult;  stdcall;
  end;


implementation

uses InvokeRegistry;

initialization
  InvRegistry.RegisterInterface(TypeInfo(GoogleSearchPort), '', '');

end.
 

Unit Unit2;

interface

uses InvokeRegistry, Types, XSBuiltIns;

type

  GoogleSearchResult = class;
  ResultElement = class;
  DirectoryCategory = class;



{ ResultElementArray }

  ResultElementArray =   array of ResultElement;


{ DirectoryCategoryArray }

  DirectoryCategoryArray =   array of DirectoryCategory;


{ GoogleSearchResult }

  GoogleSearchResult = class(TRemotable)
  private
    FdocumentFiltering: Boolean;
    FsearchComments: WideString;
    FestimatedTotalResultsCount: Integer;
    FestimateIsExact: Boolean;
    FresultElements: ResultElementArray;
    FsearchQuery: WideString;
    FstartIndex: Integer;
    FendIndex: Integer;
    FsearchTips: WideString;
    FdirectoryCategories: DirectoryCategoryArray;
    FsearchTime: Double;
  published
    property documentFiltering: Boolean read FdocumentFiltering write 
FdocumentFiltering;
    property searchComments: WideString read FsearchComments write 
FsearchComments;
    property estimatedTotalResultsCount: Integer read 
FestimatedTotalResultsCount write FestimatedTotalResultsCount;
    property estimateIsExact: Boolean read FestimateIsExact write 
FestimateIsExact;
    property resultElements: ResultElementArray read FresultElements write 
FresultElements;
    property searchQuery: WideString read FsearchQuery write FsearchQuery;
    property startIndex: Integer read FstartIndex write FstartIndex;
    property endIndex: Integer read FendIndex write FendIndex;
    property searchTips: WideString read FsearchTips write FsearchTips;
    property directoryCategories: DirectoryCategoryArray read 
FdirectoryCategories write FdirectoryCategories;
    property searchTime: Double read FsearchTime write FsearchTime;
  end;

{ ResultElement }

  ResultElement = class(TRemotable)
  private
    Fsummary: WideString;
    FURL: WideString;
    Fsnippet: WideString;
    Ftitle: WideString;
    FcachedSize: WideString;
    FrelatedInformationPresent: Boolean;
    FhostName: WideString;
    FdirectoryCategory: DirectoryCategory;
    FdirectoryTitle: WideString;
  published
    property summary: WideString read Fsummary write Fsummary;
    property URL: WideString read FURL write FURL;
    property snippet: WideString read Fsnippet write Fsnippet;
    property title: WideString read Ftitle write Ftitle;
    property cachedSize: WideString read FcachedSize write FcachedSize;
    property relatedInformationPresent: Boolean read 
FrelatedInformationPresent write FrelatedInformationPresent;
    property hostName: WideString read FhostName write FhostName;
    property directoryCategory: DirectoryCategory read FdirectoryCategory 
write FdirectoryCategory;
    property directoryTitle: WideString read FdirectoryTitle write 
FdirectoryTitle;
  end;

{ DirectoryCategory }

  DirectoryCategory = class(TRemotable)
  private
    FfullViewableName: WideString;
    FspecialEncoding: WideString;
  published
    property fullViewableName: WideString read FfullViewableName write 
FfullViewableName;
    property specialEncoding: WideString read FspecialEncoding write 
FspecialEncoding;
  end;


implementation

initialization
 
RemClassRegistry.RegisterXSClass(GoogleSearchResult,'urn:GoogleSearch','GoogleSearchResult','');
 
RemClassRegistry.RegisterXSInfo(TypeInfo(ResultElementArray),'urn:GoogleSearch','ResultElementArray','');
 
RemClassRegistry.RegisterXSInfo(TypeInfo(DirectoryCategoryArray),'urn:GoogleSearch','DirectoryCategoryArray','');
 
RemClassRegistry.RegisterXSClass(ResultElement,'urn:GoogleSearch','ResultElement','');
 
RemClassRegistry.RegisterXSClass(DirectoryCategory,'urn:GoogleSearch','DirectoryCategory','');

end.
 
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to