如何在Delphi WebService中公开复杂类型

krl*_*rlm 5 delphi soap types complextype

我在通过SOAP WebService公开DTO类时遇到了问题.

我的班级看起来像

TKontrahent = class
public
    Imie : string;
    Nazwisko : string;
    Id : integer;
end; 
Run Code Online (Sandbox Code Playgroud)

这是服务的代码:

TKontrahentService = class(TInvokableClass, IKontrahentService)
public
    function Dodaj( kontrahnet : TKontrahent)  : integer; stdcall;
    function Aktualizuj ( kontrahent : TKontrahent) : integer; stdcall;
    function Usun ( kontrahent : TKontrahent) : integer; stdcall;
    function Nowy : TKontrahent; stdcall;
end;
Run Code Online (Sandbox Code Playgroud)

以及如何在WSDL中发布类型:

<types>
  <xs:schema targetNamespace="urn:Kontrahent" xmlns="urn:Kontrahent">
    <xs:complexType name="TKontrahent">
      <xs:sequence/>
    </xs:complexType>
  </xs:schema>
</types>
Run Code Online (Sandbox Code Playgroud)

我会感谢任何建议.我找不到任何更复杂类型的样本.最好的问候,krlm

mjn*_*mjn 7

要在标准Delphi SOAP服务中公开和使用类TKontrahent,它必须是TRemotable的子类,并且必须发布其属性.

作为起点(例如在从Delphi 7迁移到2009之后),我通常会导入现有的WSDL来创建SOAP客户端并研究生成的类和属性的源代码.