2009年5月29日

Delphi 使用 WSDLImp 來建立 WebService Client Source Code

在 $(Delphi)\bin 目錄中有 WSDLImp 這個程式,
可產生 WebService Client Source Code

>WSDLImp
...
Usage: WSDLIMP [options] <WSDL[File|URL]|UDDI BindingKey>

Code Generation Options:
-C Generate C++ code -P Generate Pascal code
-R:name1;name2;name3 - Make out parameters with these names the return type
[ -option{+|-} default shown ]
-Oa- Map ambiguous classes to arrays -Oo+ One out param becomes return
-Ob- Use XMLBinding Manager for Schemas -Oq- Quiet mode (Suppress Headers)
-Od+ Generate Complex Type Destructors -Og- Use OLE GUIDs for interface
-Of- Process Faults -Os- Generate Server skeleton code
-Oi- Ignore Schema errors -Ot- Output unused types
-Ok+ Map named arrays to classes -Ou+ Unwind Literal Parameters
-Ol- Generate Literal types -Ov+ Verbose Info. in file
-On- Declare Types in Namespace -Ow+ Map strings to WideStrings
-Ox- Collapse simple Aliases
Other options:
-D<path> Output directory path -=+ Output filename after'=' in URL
-U<url of UDDI Registry> UDDI Registry [NOTE: input must be UDDI bindingkey(s)
@<Resp> Response file with list of WSDL|UDDIBindingKey to import

Proxy/Server Authentication:
-user:userName -pass:Password [-proxy:Proxy]

>WSDLImp http://api.google.com/GoogleSearch.wsdl
...
Reading: http://api.google.com/GoogleSearch.wsdl
Writing: GoogleSearch.pas
----------------------------------------------------------------------

uses
GoogleSearch;

procedure TForm1.FormCreate(Sender: TObject);
var
gs: GoogleSearchPort;
sr: GoogleSearchResult;
ra: ResultElementArray;
r: ResultElement;
I: Integer;
begin
gs := GetGoogleSearchPort(False,'http://api.google.com/search/beta2');
sr := gs.doGoogleSearch(
'?', // Google SOAP Search API 的 Key, 2006-12-05 日停發
'台中市', // query
0 ,2, // start, maxResults
False, // filter
'countryTW', //restrict 台灣地區
False, // safeSearch
'lang_zh-TW', // lr 繁體字
'UTF-8', // ie
'UTF-8'); // oe
with Memo1.Lines do
begin
Clear;
Add(FloatToStr(sr.searchTime));
ra := sr.resultElements;
for I := Low(ra) to High(ra) do
begin
r := ra[I];
Add(r.title);
Add(r.URL);
Add(r.snippet);
end;
end;
end;
{
0.019577
<b>台中市</b>政府.全球資訊網
http://www.tccg.gov.tw/
提供市府介紹、市政公告、活動、新聞、社會福利、生活資訊等。
<b>台中市</b>教育局
http://www.tceb.edu.tw/
含教育局網路導覽、公告、討論區以及各類研習線上報名系統。

}

沒有留言:

網誌存檔