Delphi 开发webservics 如何返回一个复杂的结构. ( 积分: 300 )

  • 主题发起人 主题发起人 cnzzlp
  • 开始时间 开始时间
C

cnzzlp

Unregistered / Unconfirmed
GUEST, unregistred user!
服务端:<br>1.New&amp;brvbar;WebServices&amp;brvbar;SoapServerApplication,选ISAPI(如果你想试试&nbsp;DELPHI6&nbsp;新增的&nbsp;Web&nbsp;App&nbsp;Debbuger,也可以选它,关于它我想另外再说);<br>2.SaveAll,&nbsp;Unit1命名为:MainWM,Project1命名为:SoapTest;<br>3.在MainWM中的Uses中加入:InvokeRegistry<br>4.自定义一个接口,及其对应类的实现:<br>&nbsp;&nbsp;ISoapHello&nbsp;=&nbsp;Interface&nbsp;(&nbsp;IInvokable&nbsp;)<br>&nbsp;&nbsp;['{6DF34980-6FFC-11D5-9E62-0050BABD8FE1}']&nbsp;&nbsp;//&nbsp;&nbsp;这个GUID你自己用&nbsp;Ctrl+Shift+G&nbsp;产生<br>&nbsp;&nbsp;&nbsp;&nbsp;Function&nbsp;GetHello(&nbsp;aID&nbsp;:&nbsp;Integer&nbsp;)&nbsp;:&nbsp;WideString;&nbsp;StdCall;<br>&nbsp;&nbsp;End;<br><br>&nbsp;&nbsp;TSoapHello&nbsp;=&nbsp;Class&nbsp;(&nbsp;TInvokableClass,&nbsp;ISoapHello&nbsp;)<br>&nbsp;&nbsp;Protected<br>&nbsp;&nbsp;&nbsp;&nbsp;Function&nbsp;GetHello(&nbsp;aID&nbsp;:&nbsp;Integer&nbsp;)&nbsp;:&nbsp;WideString;&nbsp;StdCall;<br>&nbsp;&nbsp;End;<br>5.实现GetHello函数:<br>Function&nbsp;TSoapHello.GetHello(&nbsp;aID&nbsp;:&nbsp;Integer&nbsp;)&nbsp;:&nbsp;WideString;<br>Begin<br>&nbsp;&nbsp;If&nbsp;(&nbsp;aID&nbsp;=&nbsp;1&nbsp;)&nbsp;Then<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;'Hello&nbsp;world!'<br>&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;'Error&nbsp;ID!';<br>End;<br>6.注册接口和类:<br>Initialization<br>&nbsp;&nbsp;InvRegistry.RegisterInterface(&nbsp;TypeInfo(&nbsp;ISoapHello&nbsp;)&nbsp;);&nbsp;<br>&nbsp;&nbsp;InvRegistry.RegisterInvokableClass(&nbsp;TSoapHello&nbsp;);<br>7.编译之即可产生:SoapTest.dll<br><br><br>简单的widestring,integer接口可以调通,请问大家如何返回一个TADOQuery,我想在这一层中查询oracle的值.用客户端来访问接口.
 
除非你把TADOQuery序列化,然后才能够传回来,没必要,直接打包数据不就可以了?
 
直接打包数据?能具体点不?webservices.方面不是很清楚[:(]
 
后退
顶部