dll封装调用java web service的问题

由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.