MSN Search Web Service使用(1)(100分)

A

autumn

Unregistered / Unconfirmed
GUEST, unregistred user!
读CSDN文档
http://www.microsoft.com/china/MSDN/library/WebServices/WebServices/msnsearch.mspx?mfr=true
后在Delphi试验。
<1>从http://soap.search.msn.com/webservices.asmx?wsdl获取wsdl文件并生成对应的pas描述文件。
<2>在delphi建立测试项目,并http://search.msn.com/developer注册获取AppID,注意要填写AppName。
<3>在注册处可以获取相对应的SDK,有详细的帮助。
<4>完成下列代码基本实现调用。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
uses a;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
iRequest:SearchRequest;
sr:ArrayOfSourceRequestRequests;
srr:ArrayOfSourceResponseResponses;
i:integer;
begin
SetLength(sr,1);
sr[0]:=SourceRequest.Create;
sr[0].Source:=Web;
sr[0].Offset:=1;
sr[0].Count:=20;
sr[0].ResultFields:='All';
iRequest:=SearchRequest.Create;
iRequest.Query:=Edit1.Text;
iRequest.Requests:=sr;
iRequest.SafeSearch:=Moderate;
iRequest.AppID:='11F6599197BD04688E0404F7A715222AF4EC7415';
iRequest.Flags:='MarkQueryWords';
iRequest.CultureInfo:='en-US';
srr:=GetMSNSearchPortType.Search(iRequest);
//接受结果(未完成)
ListBox1.Items.Add(Format('Total:%d',[srr[0].Total]));
for i := Low(srr[0].Results) to High(srr[0].Results)do
ListBox1.Items.Add(srr[0].Results.Title);

ShowMessage('Searched!');
end;

end.

附对应dfm
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 399
ClientWidth = 333
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Edit1: TEdit
Left = 24
Top = 16
Width = 297
Height = 21
TabOrder = 0
Text = 'Edit1'
end
object Button1: TButton
Left = 24
Top = 56
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 1
OnClick = Button1Click
end
object ListBox1: TListBox
Left = 24
Top = 87
Width = 297
Height = 290
ItemHeight = 13
TabOrder = 2
end
end.

问题:可以调用,但是获取的返回结果老是0.原因未找到。知道的大大请指教。
 

网中戏

Unregistered / Unconfirmed
GUEST, unregistred user!

Similar threads

I
回复
0
查看
605
import
I
I
回复
0
查看
514
import
I
I
回复
0
查看
476
import
I
I
回复
0
查看
664
import
I
顶部