dll封装调用java web service的问题

本文档总结了使用d工具根据wsdl生成接口单元时遇到的问题及解决办法,包括如何处理string类型、释放资源避免错误、处理ro工具生成的新数据类型等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

由d工具根据wsdl生成接口单元。如果生成exe调用,一切ok。但是封装成dll就出现问题了。

根据网上前人的经验总结注意事项如下:

1、有string类型的包括记录其他类型,要用按照说明使用单元ShareMem,同时发布BORLNDMM.DLL。

2、调用dll中函数后正确返回,但同时会出现错误。原因是dll和exe方式有区别。要立即释放:

var PExitProc: Pointer;
procedure exitwork;
begin
//  rmtsrvc1.FreeOnRelease;
//  rbnmsg1.FreeOnRelease;
//  rwnthtpchnl1.FreeOnRelease;

InvRegistry.Free;
InvRegistry.Destroy
end;

在dll的begin和end中处理:

begin
   PExitProc := ExitProc;  // 保存默认的善后过程地址(保护现场)

  ExitProc := @exitwork;  // 把自定义的过程的地址赋给它,然后立即执行

  ExitProc := PExitProc; // 恢复原来的默认处理函数,以便DLL能够继续完成原来默认的善后工作



end.

3、用ro工具生成的接口出现提示,生成了新的数据类型。导致接口使用异常。洒家没整明白,因为得过且过,还没研究。你知道请告诉我。

4、忘了说了,接口中把这句注释掉,如果是java写的web service。 实际前面文章以前说过了。

 

  InvRegistry.RegisterInterface(TypeInfo(YBPublisherPortType), 'http://publish/YBPublisher', 'UTF-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(YBPublisherPortType), '');
 // InvRegistry.RegisterInvokeOptions(TypeInfo(YBPublisherPortType), ioDocument);

 看前人的demo:

library dllWs;

uses
  SysUtils,
  Classes,
  Windows,
  InvokeRegistry, Rio, SOAPHTTPClient,
  TraditionalSimplifiedWebService in 'TraditionalSimplifiedWebService.pas';
var
  soapObj:TraditionalSimplifiedWebServiceSoap;

  function toTraditionalChinese(txt:WideString):WideString;stdcall;
  begin
    soapObj := GetTraditionalSimplifiedWebServiceSoap(True, 'http://www.webxml.com.cn/WebServices/TraditionalSimplifiedWebService.asmx?wsdl',nil);
    try
      Result := soapObj.toTraditionalChinese(txt);
    finally
       soapObj := nil;
    end;
  end;
{$R *.res}
  exports
    toTraditionalChinese;
    procedure DLLMain(dwReason : LongWord);
    begin
      case dwReason of
        dll_Process_attach:
        begin
        end;
        dll_Process_Detach :
        begin
        end;
      end;
    end;
begin
   DLLProc := @DLLMain;
   DLLMain(dll_Process_attach);
end.

 

转载于:https://www.cnblogs.com/usegear/archive/2013/04/17/3025959.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值