USEGEAR

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

用RO调用jave6的webservice

用RO调用jave6的webservice

java6自带webservice开发功能非常便利。那么用d调用又如何。其实也非常简单。 这里体现懒汉的优势,用ro service builder 直接生成如下:

unit SignLibrary_Intf;
 
{----------------------------------------------------------------------------}
{ This unit was automatically generated by the RemObjects SDK after reading  }
{ the RODL file associated with this project .                               }
{                                                                            }
{ Do not modify this unit manually, or your changes will be lost when this   }
{ unit is regenerated the next time you compile the project.                 }
{----------------------------------------------------------------------------}
 
{$I RemObjects.inc}
 
interface
 
uses
  {vcl:} Classes, TypInfo,
  {RemObjects:} uROXMLIntf, uROClasses, uROClient, uROTypes, uROClientIntf;
 
const
  { Library ID }
  LibraryUID = '{B0D81C3E-ADEA-40CC-8F17-9D8669D4FBDF}';
  WSDLLocation = 'http://192.168.1.78:8080/lavasoft.ServiceServer?wsdl';
  TargetNamespace = 'http://lavasoft/';
 
  { Service Interface ID's }
  IServiceServerService_IID : TGUID = '{4160302F-5F1E-4424-89E8-950285727951}';
  ServiceServerService_EndPointURI = 'http://192.168.1.78:8080/lavasoft.ServiceServer';
 
type
  TSeekOrigin = Classes.TSeekOrigin; // fake declaration
  { Forward declarations }
  IServiceServerService = interface;
 
 
  { IServiceServerService }
  IServiceServerService = interface
    ['{4160302F-5F1E-4424-89E8-950285727951}']
    function doSomething(const doSomething: UnicodeString): UnicodeString;
  end;
 
  { CoServiceServerService }
  CoServiceServerService = class
    class function Create(const aMessage: IROMessage; aTransportChannel: IROTransportChannel): IServiceServerService;
  end;
 
  { TServiceServerService_Proxy }
  TServiceServerService_Proxy = class(TROProxy, IServiceServerService)
  protected
    function __GetInterfaceName:string; override;
 
    function doSomething(const doSomething: UnicodeString): UnicodeString;
  end;
 
implementation
 
uses
  {vcl:} SysUtils,
  {RemObjects:} uROEventRepository, uROSerializer, uRORes;
 
{ CoServiceServerService }
 
class function CoServiceServerService.Create(const aMessage: IROMessage; aTransportChannel: IROTransportChannel): IServiceServerService;
begin
  Result := TServiceServerService_Proxy.Create(aMessage, aTransportChannel);
end;
 
{ TServiceServerService_Proxy }
 
function TServiceServerService_Proxy.__GetInterfaceName:string;
begin
  Result := 'ServiceServerService';
end;
 
function TServiceServerService_Proxy.doSomething(const doSomething: UnicodeString): UnicodeString;
var
  lMessage: IROMessage;
  lTransportChannel: IROTransportChannel;
begin
  lMessage := __GetMessage;
  lTransportChannel := __TransportChannel;
    lMessage.SetAttributes(lTransportChannel, ['InputImportedFromUrl', 'Location', 'OutputImportedFromUrl', 'SoapActionIsEmpty', 'SOAPInputNameOverride', 'SOAPOutputNameOverride', 'TargetNamespace'
      , 'Type', 'Use', 'Wsdl'],
      ['lavasoft.ServiceServer?xsd=1', 'http://192.168.1.78:8080/lavasoft.ServiceServer', 'lavasoft.ServiceServer?xsd=1', '1', 'doSomething', 'doSomethingResponse', TargetNamespace
      , 'SOAP', 'literal', WSDLLocation]);
  try
    lMessage.InitializeRequestMessage(lTransportChannel, 'SignLibrary', __InterfaceName, 'doSomething');
    lMessage.Write('doSomething', TypeInfo(UnicodeString), doSomething, []);
    lMessage.Finalize;
 
    lTransportChannel.Dispatch(lMessage);
 
    lMessage.Read('return', TypeInfo(UnicodeString), Result, []);
  finally
    lMessage.UnsetAttributes(lTransportChannel);
    lMessage.FreeStream;
    lMessage := nil;
    lTransportChannel := nil;
  end;
end;
 
initialization
  RegisterProxyClass(IServiceServerService_IID, TServiceServerService_Proxy);
 
 
finalization
  UnregisterProxyClass(IServiceServerService_IID);
 
 
end.

  

=================

看调用:

procedure TForm1.Button2Click(Sender: TObject);
var
  myCoServiceServerService : IServiceServerService;
begin
  myCoServiceServerService := CoServiceServerService.Create(ROSOAPMessage1,ROWinInetHTTPChannel1);
  edt1.Text := myCoServiceServerService.doSomething('12312');
end;

 

procedure TForm1.Button2Click(Sender: TObject); var myCoServiceServerService : IServiceServerService; begin myCoServiceServerService := CoServiceServerService.Create(ROSOAPMessage1,ROWinInetHTTPChannel1); edt1.Text := myCoServiceServerService.doSomething('12312'); end;

====================

结果如下 :

 

爽吧!

爽极了!

posted on   USEGEAR  阅读(462)  评论(0编辑  收藏  举报

编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
点击右上角即可分享
微信分享提示