在导入的WSDL Delphi中键入值

时间:2019-01-12 22:27:39

标签: xml delphi types wsdl

我已经导入了已声明各种类型的WSDL文件。一些类型声明为其他类型。我想为各种类型的元素提供值,但收到“访问冲突”错误。在这种情况下,此行给我一个错误:req.Body.Pack.sn:='1234'; 请您帮我,我的代码中缺少什么?如何在WSDL请求中提供各种类型的值?

导入的WSDL:

  // ************************************************************************ //
  // XML       : G110Request, global, <element>
  // Namespace : urn:wsdltypes.nmvs.eu:v3.0
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  G110Request = class(I1_SinglePack_Type)
  private
  public
    constructor Create; override;
  published
  end;

  // ************************************************************************ //
  // XML       : I1_SinglePack_Type, global, <complexType>
  // Namespace : urn:types.nmvs.eu:v3.0
  // ************************************************************************ //
  I1_SinglePack_Type = class(Header_Type)
  private
    FBody: RequestData_Type;
  public
    destructor Destroy; override;
  published
    property Body: RequestData_Type  read FBody write FBody;
  end;

  // ************************************************************************ //
  // XML       : RequestData_Type, global, <complexType>
  // Namespace : urn:types.nmvs.eu:v3.0
  // ************************************************************************ //
  RequestData_Type = class(TRemotable)
  private
    FProduct: RequestProduct_Type;
    FPack: RequestPack_Type;
  public
    destructor Destroy; override;
  published
    property Product: RequestProduct_Type  read FProduct write FProduct;
    property Pack:    RequestPack_Type     read FPack write FPack;
  end;

  // ************************************************************************ //
  // XML       : RequestPack_Type, global, <complexType>
  // Namespace : urn:types.nmvs.eu:v3.0
  // ************************************************************************ //
  RequestPack_Type = class(TRemotable)
  private
    Fsn: SN_Type;
  published
    property sn: SN_Type  Index (IS_ATTR or IS_QUAL) read Fsn write Fsn;
  end;

  SN_Type         =  type string;      { "urn:types.nmvs.eu:v3.0"[GblSmpl] }

我的代码:

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,
  WS_SINGLE_PACK;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  WS: ISinglePackServices;
  req: G110Request;
  res: G110Response;

begin
  WS:= GetISinglePackServices;
  req:= G110Request.Create;
  res:= G110Response.Create;

  req.Body.Pack.sn:= '1234';

  res:= WS.G110Verify(req);
end;

end.

0 个答案:

没有答案