这个Webservice如何调用啊

时间:2021-10-20 08:47:26
大家好,现在有这样一个Webservice,请教在客户端如何调用它啊??
unit oneclient_v2;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

const
  IS_OPTN = $0001;
  IS_UNBD = $0002;
  IS_UNQL = $0008;


type


  OneClientCustomerPolicy = class;              { "http://www.xyz.com/oneclient-v2/"[Lit][GblCplx] }
  Customer             = class;                 { "http://www.xyz.com/oneclient-v2/"[GblCplx] }
  Policy               = class;                 { "http://www.xyz.com/oneclient-v2/"[GblCplx] }
  PaymentDetails       = class;                 { "http://www.xyz.com/oneclient-v2/"[GblCplx] }
  WarrantyDetail       = class;                 { "http://www.xyz.com/oneclient-v2/"[GblCplx] }
  DirectDebitPayType   = class;                 { "http://www.xyz.com/oneclient-v2/"[GblCplx] }
  PolicyList           = class;                 { "http://www.xyz.com/oneclient-v2/"[GblCplx] }
  Errors               = class;                 { "http://www.xyz.com/oneclient-v2/"[GblCplx] }
  ErrorList            = class;                 { "http://www.xyz.com/oneclient-v2/"[GblCplx] }
  CreditCardPayType    = class;                 { "http://www.xyz.com/oneclient-v2/"[GblCplx] }
  InsertPolicy         = class;                 { "http://www.xyz.com/oneclient-v2/"[Lit][GblElm] }
  InsertPolicyResponse = class;                 { "http://www.xyz.com/oneclient-v2/"[Lit][GblCplx] }
  InsertPolicyResponse2 = class;                { "http://www.xyz.com/oneclient-v2/"[Lit][GblElm] }

  { "http://www.xyz.com/oneclient-v2/"[Smpl] }
  CustomerType = (d, c);

  { "http://www.xyz.com/oneclient-v2/"[Smpl] }
  Country = (GB);

  { "http://www.xyz.com/oneclient-v2/"[Smpl] }
  SpecialNeeds = (blind, braille, deaf, lgprint);

  { "http://www.xyz.com/oneclient-v2/"[Smpl] }
  SalesType = (Post, Scanner, Tele, Web);

  { "http://www.xyz.com/oneclient-v2/"[Smpl] }
  PayType = (CCA, CCM, DDA, DDM, DDQ, DDT);

  { "http://www.xyz.com/oneclient-v2/"[Smpl] }
  CardType = (DBS, DBD, CCV, CCM2);

  Policies   = array of Policy;                 { "http://www.xyz.com/oneclient-v2/"[GblCplx] }


  OneClientCustomerPolicy = class(TRemotable)
  private
    FOneClientChannel: WideString;
    FTransactionID: WideString;
    FCustomer: Customer;
    FAlternativeCustomer: Customer;
    FPolicies: Policies;
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property OneClientChannel:    WideString  Index (IS_UNQL) read FOneClientChannel write FOneClientChannel;
    property TransactionID:       WideString  Index (IS_UNQL) read FTransactionID write FTransactionID;
    property Customer:            Customer    Index (IS_UNQL) read FCustomer write FCustomer;
    property AlternativeCustomer: Customer    Index (IS_UNQL) read FAlternativeCustomer write FAlternativeCustomer;
    property Policies:            Policies    Index (IS_UNQL) read FPolicies write FPolicies;
  end;



  // ************************************************************************ //
  // XML       : Customer, global, <complexType>
  // Namespace : http://www.xyz.com/oneclient-v2/
  // ************************************************************************ //
  Customer = class(TRemotable)
  private
    FCustomerType: CustomerType;
    FCompanyName: WideString;
    FTitle: WideString;
    FInitials: WideString;
    FSurname: WideString;
    FFlatNo: WideString;
    FHouseNo: WideString;
    FAddressLine1: WideString;
    FAddressLine2: WideString;
    FAddressLine3: WideString;
    FAddressLine4: WideString;
    FAddressLine5: WideString;
    FPostCode: WideString;
    FCountry: Country;
    FDateOfBirth: TXSDate;
    FHomePhone: WideString;
    FMobilePhone: WideString;
    FWorkPhone: WideString;
    FSpecialNeeds: SpecialNeeds;
    FEmailAddress: WideString;
    FNoTeleSales3rdParty: Boolean;
    FNoTeleSales: Boolean;
    FNoMail3rdParty: Boolean;
    FNoMail: Boolean;
    FNoSms: Boolean;
    FNoEmail: Boolean;
  public
    destructor Destroy; override;
  published
    property CustomerType:        CustomerType  Index (IS_UNQL) read FCustomerType write FCustomerType;
    property CompanyName:         WideString    Index (IS_UNQL) read FCompanyName write FCompanyName;
    property Title:               WideString    Index (IS_UNQL) read FTitle write FTitle;
    property Initials:            WideString    Index (IS_UNQL) read FInitials write FInitials;
    property Surname:             WideString    Index (IS_UNQL) read FSurname write FSurname;
    property FlatNo:              WideString    Index (IS_UNQL) read FFlatNo write FFlatNo;
    property HouseNo:             WideString    Index (IS_UNQL) read FHouseNo write FHouseNo;
    property AddressLine1:        WideString    Index (IS_UNQL) read FAddressLine1 write FAddressLine1;
    property AddressLine2:        WideString    Index (IS_UNQL) read FAddressLine2 write FAddressLine2;
    property AddressLine3:        WideString    Index (IS_UNQL) read FAddressLine3 write FAddressLine3;
    property AddressLine4:        WideString    Index (IS_UNQL) read FAddressLine4 write FAddressLine4;
    property AddressLine5:        WideString    Index (IS_UNQL) read FAddressLine5 write FAddressLine5;
    property PostCode:            WideString    Index (IS_UNQL) read FPostCode write FPostCode;
    property Country:             Country       Index (IS_UNQL) read FCountry write FCountry;
    property DateOfBirth:         TXSDate       Index (IS_UNQL) read FDateOfBirth write FDateOfBirth;
    property HomePhone:           WideString    Index (IS_UNQL) read FHomePhone write FHomePhone;
    property MobilePhone:         WideString    Index (IS_UNQL) read FMobilePhone write FMobilePhone;
    property WorkPhone:           WideString    Index (IS_UNQL) read FWorkPhone write FWorkPhone;
    property SpecialNeeds:        SpecialNeeds  Index (IS_UNQL) read FSpecialNeeds write FSpecialNeeds;
    property EmailAddress:        WideString    Index (IS_UNQL) read FEmailAddress write FEmailAddress;
    property NoTeleSales3rdParty: Boolean       Index (IS_UNQL) read FNoTeleSales3rdParty write FNoTeleSales3rdParty;
    property NoTeleSales:         Boolean       Index (IS_UNQL) read FNoTeleSales write FNoTeleSales;
    property NoMail3rdParty:      Boolean       Index (IS_UNQL) read FNoMail3rdParty write FNoMail3rdParty;
    property NoMail:              Boolean       Index (IS_UNQL) read FNoMail write FNoMail;
    property NoSms:               Boolean       Index (IS_UNQL) read FNoSms write FNoSms;
    property NoEmail:             Boolean       Index (IS_UNQL) read FNoEmail write FNoEmail;
  end;


  Policy = class(TRemotable)
  private
    FMailCode: WideString;
    FAreaCode: WideString;
    FSalePrice: WideString;
    FStartDate: TXSDate;
    FSalesType: SalesType;
    FAgentId: WideString;
    FPayType: PayType;
    FPaymentDetail: PaymentDetails;
    FWarrantyDetail: WarrantyDetail;
  public
    destructor Destroy; override;
  published
    property MailCode:       WideString      Index (IS_UNQL) read FMailCode write FMailCode;
    property AreaCode:       WideString      Index (IS_UNQL) read FAreaCode write FAreaCode;
    property SalePrice:      WideString      Index (IS_UNQL) read FSalePrice write FSalePrice;
    property StartDate:      TXSDate         Index (IS_UNQL) read FStartDate write FStartDate;
    property SalesType:      SalesType       Index (IS_UNQL) read FSalesType write FSalesType;
    property AgentId:        WideString      Index (IS_UNQL) read FAgentId write FAgentId;
    property PayType:        PayType         Index (IS_UNQL) read FPayType write FPayType;
    property PaymentDetail:  PaymentDetails  Index (IS_UNQL) read FPaymentDetail write FPaymentDetail;
    property WarrantyDetail: WarrantyDetail  Index (IS_UNQL) read FWarrantyDetail write FWarrantyDetail;
  end;

  PaymentDetails = class(TRemotable)
  private
    FCreditCardPayType: CreditCardPayType;
    FDirectDebitPayType: DirectDebitPayType;
  public
    destructor Destroy; override;
  published
    property CreditCardPayType:  CreditCardPayType   Index (IS_UNQL) read FCreditCardPayType write FCreditCardPayType;
    property DirectDebitPayType: DirectDebitPayType  Index (IS_UNQL) read FDirectDebitPayType write FDirectDebitPayType;
  end;

8 个解决方案

#1


续上

  WarrantyDetail = class(TRemotable)
  private
    FGroup: WideString;
    FManufacturer: WideString;
    FType_: WideString;
    FModel: WideString;
    FInstallationDate: TXSDate;
    FPurchasePrice: WideString;
    FSerialNo: WideString;
    FResidualStatus: WideString;
    FCatalogueNumber: WideString;
    FLocationNo: WideString;
  public
    destructor Destroy; override;
  published
    property Group:            WideString  Index (IS_UNQL) read FGroup write FGroup;
    property Manufacturer:     WideString  Index (IS_UNQL) read FManufacturer write FManufacturer;
    property Type_:            WideString  Index (IS_UNQL) read FType_ write FType_;
    property Model:            WideString  Index (IS_UNQL) read FModel write FModel;
    property InstallationDate: TXSDate     Index (IS_UNQL) read FInstallationDate write FInstallationDate;
    property PurchasePrice:    WideString  Index (IS_UNQL) read FPurchasePrice write FPurchasePrice;
    property SerialNo:         WideString  Index (IS_UNQL) read FSerialNo write FSerialNo;
    property ResidualStatus:   WideString  Index (IS_UNQL) read FResidualStatus write FResidualStatus;
    property CatalogueNumber:  WideString  Index (IS_UNQL) read FCatalogueNumber write FCatalogueNumber;
    property LocationNo:       WideString  Index (IS_UNQL) read FLocationNo write FLocationNo;
  end;

  DirectDebitPayType = class(TRemotable)
  private
    FAccountNumber: WideString;
    FSortCode: WideString;
    FPaymentDay: WideString;
    FAccountTitle: WideString;
  published
    property AccountNumber: WideString  Index (IS_UNQL) read FAccountNumber write FAccountNumber;
    property SortCode:      WideString  Index (IS_UNQL) read FSortCode write FSortCode;
    property PaymentDay:    WideString  Index (IS_UNQL) read FPaymentDay write FPaymentDay;
    property AccountTitle:  WideString  Index (IS_UNQL) read FAccountTitle write FAccountTitle;
  end;

  PolicyList = class(TRemotable)
  private
    FPolicyRef: WideString;
    FMailCode: WideString;
    FAreaCode: WideString;
    FSalePrice: WideString;
    FPolicyTypeDesc: WideString;
    FPayMethod: WideString;
    FPolicyLength: WideString;
    FDelayDays: WideString;
    FPeriodFrom: WideString;
    FPeriodTo: WideString;
  published
    property PolicyRef:      WideString  Index (IS_UNQL) read FPolicyRef write FPolicyRef;
    property MailCode:       WideString  Index (IS_UNQL) read FMailCode write FMailCode;
    property AreaCode:       WideString  Index (IS_UNQL) read FAreaCode write FAreaCode;
    property SalePrice:      WideString  Index (IS_UNQL) read FSalePrice write FSalePrice;
    property PolicyTypeDesc: WideString  Index (IS_UNQL) read FPolicyTypeDesc write FPolicyTypeDesc;
    property PayMethod:      WideString  Index (IS_UNQL) read FPayMethod write FPayMethod;
    property PolicyLength:   WideString  Index (IS_UNQL) read FPolicyLength write FPolicyLength;
    property DelayDays:      WideString  Index (IS_UNQL) read FDelayDays write FDelayDays;
    property PeriodFrom:     WideString  Index (IS_UNQL) read FPeriodFrom write FPeriodFrom;
    property PeriodTo:       WideString  Index (IS_UNQL) read FPeriodTo write FPeriodTo;
  end;

  Errors = class(TRemotable)
  private
    FError: ErrorList;
  public
    destructor Destroy; override;
  published
    property Error: ErrorList  Index (IS_UNQL) read FError write FError;
  end;


  ErrorList = class(TRemotable)
  private
    FErrorCode: WideString;
    FDescription: WideString;
  published
    property ErrorCode:   WideString  Index (IS_UNQL) read FErrorCode write FErrorCode;
    property Description: WideString  Index (IS_UNQL) read FDescription write FDescription;
  end;

  CreditCardPayType = class(TRemotable)
  private
    FCardNumber: WideString;
    FCardName: WideString;
    FCardFromDate: WideString;
    FCardExpiryDate: WideString;
    FCardIssueNo: WideString;
    FCV2: WideString;
    FCardType: CardType;
    FCreditCardFlatNo: WideString;
    FCreditCardHouseNo: WideString;
    FCreditCardAddressLine1: WideString;
    FCreditCardAddressLine2: WideString;
    FCreditCardAddressLine3: WideString;
    FCreditCardAddressLine4: WideString;
    FCreditCardAddressLine5: WideString;
    FCreditCardPostCode: WideString;
    FPaymentDay: WideString;
  published
    property CardNumber:             WideString  Index (IS_UNQL) read FCardNumber write FCardNumber;
    property CardName:               WideString  Index (IS_UNQL) read FCardName write FCardName;
    property CardFromDate:           WideString  Index (IS_UNQL) read FCardFromDate write FCardFromDate;
    property CardExpiryDate:         WideString  Index (IS_UNQL) read FCardExpiryDate write FCardExpiryDate;
    property CardIssueNo:            WideString  Index (IS_UNQL) read FCardIssueNo write FCardIssueNo;
    property CV2:                    WideString  Index (IS_UNQL) read FCV2 write FCV2;
    property CardType:               CardType    Index (IS_UNQL) read FCardType write FCardType;
    property CreditCardFlatNo:       WideString  Index (IS_UNQL) read FCreditCardFlatNo write FCreditCardFlatNo;
    property CreditCardHouseNo:      WideString  Index (IS_UNQL) read FCreditCardHouseNo write FCreditCardHouseNo;
    property CreditCardAddressLine1: WideString  Index (IS_UNQL) read FCreditCardAddressLine1 write FCreditCardAddressLine1;
    property CreditCardAddressLine2: WideString  Index (IS_UNQL) read FCreditCardAddressLine2 write FCreditCardAddressLine2;
    property CreditCardAddressLine3: WideString  Index (IS_UNQL) read FCreditCardAddressLine3 write FCreditCardAddressLine3;
    property CreditCardAddressLine4: WideString  Index (IS_UNQL) read FCreditCardAddressLine4 write FCreditCardAddressLine4;
    property CreditCardAddressLine5: WideString  Index (IS_UNQL) read FCreditCardAddressLine5 write FCreditCardAddressLine5;
    property CreditCardPostCode:     WideString  Index (IS_UNQL) read FCreditCardPostCode write FCreditCardPostCode;
    property PaymentDay:             WideString  Index (IS_UNQL) read FPaymentDay write FPaymentDay;
  end;


  InsertPolicy = class(OneClientCustomerPolicy)
  private
  published
  end;

  Array_Of_Errors = array of Errors;            { "http://www.xyz.com/oneclient-v2/"[GblUbnd] }

  InsertPolicyResponse = class(TRemotable)
  private
    FCustomerRef: WideString;
    FPolicies: PolicyList;
    FErrors: Array_Of_Errors;
    FErrors_Specified: boolean;
    procedure SetErrors(Index: Integer; const AArray_Of_Errors: Array_Of_Errors);
    function  Errors_Specified(Index: Integer): boolean;
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property CustomerRef: WideString       Index (IS_UNQL) read FCustomerRef write FCustomerRef;
    property Policies:    PolicyList       Index (IS_UNQL) read FPolicies write FPolicies;
    property Errors:      Array_Of_Errors  Index (IS_OPTN or IS_UNBD or IS_UNQL) read FErrors write SetErrors stored Errors_Specified;
  end;


#2


续上  

InsertPolicyResponse2 = class(InsertPolicyResponse)
  private
  published
  end;


  // ************************************************************************ //
  // Namespace : http://www.xyz.com/oneclient-v2/
  // soapAction: http://www.xyz.com/oneclient/InsertPolicy
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : document
  // binding   : oneclientSOAP
  // service   : oneclient
  // port      : oneclientSOAP
  // URL       : http://12.12.12.12:3501/oneclient?wsdl
  // ************************************************************************ //
  oneclient = interface(IInvokable)
  ['{350E6DE8-CBD2-4F26-4466-7604F9206B25}']

    // Cannot unwrap: 
    //     - More than one strictly out element was found
    function  InsertPolicy(const InsertPolicy: InsertPolicy): InsertPolicyResponse2; stdcall;
  end;

function Getoneclient(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): oneclient;


implementation
  uses SysUtils;

function Getoneclient(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): oneclient;
const
  defWSDL = 'L:\ABCLtd\Clients\XYZ\HomeServe\oneclient-v2.wsdl';
  defURL  = 'http://12.12.12.12:3501/oneclient?wsdl';
  defSvc  = 'oneclient';
  defPrt  = 'oneclientSOAP';
var
  RIO: THTTPRIO;
begin
  Result := nil;
  if (Addr = '') then
  begin
    if UseWSDL then
      Addr := defWSDL
    else
      Addr := defURL;
  end;
  if HTTPRIO = nil then
    RIO := THTTPRIO.Create(nil)
  else
    RIO := HTTPRIO;
  try
    Result := (RIO as oneclient);
    if UseWSDL then
    begin
      RIO.WSDLLocation := Addr;
      RIO.Service := defSvc;
      RIO.Port := defPrt;
    end else
      RIO.URL := Addr;
  finally
    if (Result = nil) and (HTTPRIO = nil) then
      RIO.Free;
  end;
end;


constructor OneClientCustomerPolicy.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

destructor OneClientCustomerPolicy.Destroy;
var
  I: Integer;
begin
  for I := 0 to Length(FPolicies)-1 do
    FreeAndNil(FPolicies[I]);
  SetLength(FPolicies, 0);
  FreeAndNil(FCustomer);
  FreeAndNil(FAlternativeCustomer);
  inherited Destroy;
end;

destructor Customer.Destroy;
begin
  FreeAndNil(FDateOfBirth);
  inherited Destroy;
end;

destructor Policy.Destroy;
begin
  FreeAndNil(FStartDate);
  FreeAndNil(FPaymentDetail);
  FreeAndNil(FWarrantyDetail);
  inherited Destroy;
end;

destructor PaymentDetails.Destroy;
begin
  FreeAndNil(FCreditCardPayType);
  FreeAndNil(FDirectDebitPayType);
  inherited Destroy;
end;

destructor WarrantyDetail.Destroy;
begin
  FreeAndNil(FInstallationDate);
  inherited Destroy;
end;

destructor Errors.Destroy;
begin
  FreeAndNil(FError);
  inherited Destroy;
end;

constructor InsertPolicyResponse.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

destructor InsertPolicyResponse.Destroy;
var
  I: Integer;
begin
  for I := 0 to Length(FErrors)-1 do
    FreeAndNil(FErrors[I]);
  SetLength(FErrors, 0);
  FreeAndNil(FPolicies);
  inherited Destroy;
end;

procedure InsertPolicyResponse.SetErrors(Index: Integer; const AArray_Of_Errors: Array_Of_Errors);
begin
  FErrors := AArray_Of_Errors;
  FErrors_Specified := True;
end;

function InsertPolicyResponse.Errors_Specified(Index: Integer): boolean;
begin
  Result := FErrors_Specified;
end;

initialization
  InvRegistry.RegisterInterface(TypeInfo(oneclient), 'http://www.xyz.com/oneclient-v2/', 'UTF-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(oneclient), 'http://www.xyz.com/oneclient/InsertPolicy');
  InvRegistry.RegisterInvokeOptions(TypeInfo(oneclient), ioDocument);
  InvRegistry.RegisterInvokeOptions(TypeInfo(oneclient), ioLiteral);
  RemClassRegistry.RegisterXSInfo(TypeInfo(Policies), 'http://www.xyz.com/oneclient-v2/', 'Policies');
  RemClassRegistry.RegisterXSClass(OneClientCustomerPolicy, 'http://www.xyz.com/oneclient-v2/', 'OneClientCustomerPolicy');
  RemClassRegistry.RegisterSerializeOptions(OneClientCustomerPolicy, [xoLiteralParam]);
  RemClassRegistry.RegisterXSInfo(TypeInfo(CustomerType), 'http://www.xyz.com/oneclient-v2/', 'CustomerType');
  RemClassRegistry.RegisterXSInfo(TypeInfo(Country), 'http://www.xyz.com/oneclient-v2/', 'Country');
  RemClassRegistry.RegisterXSInfo(TypeInfo(SpecialNeeds), 'http://www.xyz.com/oneclient-v2/', 'SpecialNeeds');
  RemClassRegistry.RegisterXSClass(Customer, 'http://www.xyz.com/oneclient-v2/', 'Customer');
  RemClassRegistry.RegisterXSInfo(TypeInfo(SalesType), 'http://www.xyz.com/oneclient-v2/', 'SalesType');
  RemClassRegistry.RegisterXSInfo(TypeInfo(PayType), 'http://www.xyz.com/oneclient-v2/', 'PayType');
  RemClassRegistry.RegisterXSClass(Policy, 'http://www.xyz.com/oneclient-v2/', 'Policy');
  RemClassRegistry.RegisterXSClass(PaymentDetails, 'http://www.xyz.com/oneclient-v2/', 'PaymentDetails');
  RemClassRegistry.RegisterXSClass(WarrantyDetail, 'http://www.xyz.com/oneclient-v2/', 'WarrantyDetail');
  RemClassRegistry.RegisterExternalPropName(TypeInfo(WarrantyDetail), 'Type_', 'Type');
  RemClassRegistry.RegisterXSClass(DirectDebitPayType, 'http://www.xyz.com/oneclient-v2/', 'DirectDebitPayType');
  RemClassRegistry.RegisterXSClass(PolicyList, 'http://www.xyz.com/oneclient-v2/', 'PolicyList');
  RemClassRegistry.RegisterXSClass(Errors, 'http://www.xyz.com/oneclient-v2/', 'Errors');
  RemClassRegistry.RegisterXSClass(ErrorList, 'http://www.xyz.com/oneclient-v2/', 'ErrorList');
  RemClassRegistry.RegisterXSInfo(TypeInfo(CardType), 'http://www.xyz.com/oneclient-v2/', 'CardType');
  RemClassRegistry.RegisterExternalPropName(TypeInfo(CardType), 'CCM2', 'CCM');
  RemClassRegistry.RegisterXSClass(CreditCardPayType, 'http://www.xyz.com/oneclient-v2/', 'CreditCardPayType');
  RemClassRegistry.RegisterXSClass(InsertPolicy, 'http://www.xyz.com/oneclient-v2/', 'InsertPolicy');
  RemClassRegistry.RegisterXSInfo(TypeInfo(Array_Of_Errors), 'http://www.xyz.com/oneclient-v2/', 'Array_Of_Errors');
  RemClassRegistry.RegisterXSClass(InsertPolicyResponse, 'http://www.xyz.com/oneclient-v2/', 'InsertPolicyResponse');
  RemClassRegistry.RegisterSerializeOptions(InsertPolicyResponse, [xoLiteralParam]);
  RemClassRegistry.RegisterXSClass(InsertPolicyResponse2, 'http://www.xyz.com/oneclient-v2/', 'InsertPolicyResponse2', 'InsertPolicyResponse');

end.

最好有实例,谢谢大家啦

#3


晕,没人回复哦

#4


看下这个帖子吧
http://topic.csdn.net/u/20080325/17/67fa9173-246d-4d51-a465-13a1db6358b9.html

#5



oneclient = interface(IInvokable)
  ['{350E6DE8-CBD2-4F26-4466-7604F9206B25}']

    // Cannot unwrap:
    //    - More than one strictly out element was found
    function  InsertPolicy(const InsertPolicy: InsertPolicy): InsertPolicyResponse2; stdcall;
  end; 
用HTTPRIO调用这个接口
Var
  p : oneclient ; 
begin
  p := HTTPRIO As oneclient ;
  p.InsertPolicy(InsertPolicy); //InsertPolicy需要创建一个OneClientCustomerPolicy的类,把相关属性添进去就行了
  p:=nil;
end;

#6


非常感谢liangpei2008的回复,我试一下子看看。另外,如果对方的Webservice需要https连接,不知道在Delphi中如何设置认证。比如说对方: https://testws.abc.com:3501/oneclient-v2 同时给你一个用户名与密码。

#7


又碰到新问题了,实例化了一个InsertPolicy, 在添加相关属性的时候,InsertPolicy有一个属性Policies, 它是一个Policy 的数组,如何赋修值。

Policies  = array of Policy;

下面是我的代码:

  FzInsertPolicy :=InsertPolicy.Create;
  FzCustomer := Customer.Create;
  FzAlternativeCustomer := Customer.Create;
  FzPolicy := Policy.Create;
  FzPaymentDetails := PaymentDetails.Create;
  FzCreditCardPayType := CreditCardPayType.Create;
  FzDirectDebitPayType := DirectDebitPayType.Create;
  FzWarrantyDetail := WarrantyDetail.Create;

  with FzInsertPolicy do
  begin
   OneClientChannel := 'FzOneClientChannel';
   TransactionID := 'Fz201002050000001';
   Customer := FzCustomer;
   AlternativeCustomer := FzAlternativeCustomer;
   Policies := 这里怎么写?????;
  end;

  with FzCustomer do
  begin
    CustomerType := d;
    //CompanyName  := '';
    Title  := 'Mr';
    Initials  := 'David';
    Surname  := 'Xu';
    ......
  end;

  with FzAlternativeCustomer do
  begin
     CustomerType := d;
    //CompanyName  := '';
    Title  := 'Mr';
    Initials  := 'David';
    Surname  := 'Xu';
    ......
  end;


  with FzPolicy do
  begin
     MailCode := '';
     AreaCode := '';
     SalePrice := '';
     //StartDate := '';
     //SalesType := '';
     AgentId := '';
     //PayType := '';
     PaymentDetail := FzPaymentDetails;
     WarrantyDetail := FzWarrantyDetail;
  end;

  with FzPaymentDetails do
  begin
    CreditCardPayType := FzCreditCardPayType;
    DirectDebitPayType := FzDirectDebitPayType;
  end;

  with FzCreditCardPayType do
  begin
    CardNumber := '';
    CardName := '';
    ....
  end;

  with FzDirectDebitPayType do
  begin
    AccountNumber := '';
    SortCode := '';
    ....
  end;

  with FzWarrantyDetail do
  begin
   Group := '';
   Manufacturer := '';
   .....
  end;

FzPolicies  是 FzPolicy的一个数组,不知道如何将FzPolicy赋值给FzPolicies????晕啊

#8


数组的问题自己研究解决了,还剩最后的一个问题,就是认证的问题。

它的webservice 是基于https的,对方给了我一个用户名笥密码,怎样才能验证呢?不知道如何操作?

它的wsdl文件中没有找到任何验证的接口。

#1


续上

  WarrantyDetail = class(TRemotable)
  private
    FGroup: WideString;
    FManufacturer: WideString;
    FType_: WideString;
    FModel: WideString;
    FInstallationDate: TXSDate;
    FPurchasePrice: WideString;
    FSerialNo: WideString;
    FResidualStatus: WideString;
    FCatalogueNumber: WideString;
    FLocationNo: WideString;
  public
    destructor Destroy; override;
  published
    property Group:            WideString  Index (IS_UNQL) read FGroup write FGroup;
    property Manufacturer:     WideString  Index (IS_UNQL) read FManufacturer write FManufacturer;
    property Type_:            WideString  Index (IS_UNQL) read FType_ write FType_;
    property Model:            WideString  Index (IS_UNQL) read FModel write FModel;
    property InstallationDate: TXSDate     Index (IS_UNQL) read FInstallationDate write FInstallationDate;
    property PurchasePrice:    WideString  Index (IS_UNQL) read FPurchasePrice write FPurchasePrice;
    property SerialNo:         WideString  Index (IS_UNQL) read FSerialNo write FSerialNo;
    property ResidualStatus:   WideString  Index (IS_UNQL) read FResidualStatus write FResidualStatus;
    property CatalogueNumber:  WideString  Index (IS_UNQL) read FCatalogueNumber write FCatalogueNumber;
    property LocationNo:       WideString  Index (IS_UNQL) read FLocationNo write FLocationNo;
  end;

  DirectDebitPayType = class(TRemotable)
  private
    FAccountNumber: WideString;
    FSortCode: WideString;
    FPaymentDay: WideString;
    FAccountTitle: WideString;
  published
    property AccountNumber: WideString  Index (IS_UNQL) read FAccountNumber write FAccountNumber;
    property SortCode:      WideString  Index (IS_UNQL) read FSortCode write FSortCode;
    property PaymentDay:    WideString  Index (IS_UNQL) read FPaymentDay write FPaymentDay;
    property AccountTitle:  WideString  Index (IS_UNQL) read FAccountTitle write FAccountTitle;
  end;

  PolicyList = class(TRemotable)
  private
    FPolicyRef: WideString;
    FMailCode: WideString;
    FAreaCode: WideString;
    FSalePrice: WideString;
    FPolicyTypeDesc: WideString;
    FPayMethod: WideString;
    FPolicyLength: WideString;
    FDelayDays: WideString;
    FPeriodFrom: WideString;
    FPeriodTo: WideString;
  published
    property PolicyRef:      WideString  Index (IS_UNQL) read FPolicyRef write FPolicyRef;
    property MailCode:       WideString  Index (IS_UNQL) read FMailCode write FMailCode;
    property AreaCode:       WideString  Index (IS_UNQL) read FAreaCode write FAreaCode;
    property SalePrice:      WideString  Index (IS_UNQL) read FSalePrice write FSalePrice;
    property PolicyTypeDesc: WideString  Index (IS_UNQL) read FPolicyTypeDesc write FPolicyTypeDesc;
    property PayMethod:      WideString  Index (IS_UNQL) read FPayMethod write FPayMethod;
    property PolicyLength:   WideString  Index (IS_UNQL) read FPolicyLength write FPolicyLength;
    property DelayDays:      WideString  Index (IS_UNQL) read FDelayDays write FDelayDays;
    property PeriodFrom:     WideString  Index (IS_UNQL) read FPeriodFrom write FPeriodFrom;
    property PeriodTo:       WideString  Index (IS_UNQL) read FPeriodTo write FPeriodTo;
  end;

  Errors = class(TRemotable)
  private
    FError: ErrorList;
  public
    destructor Destroy; override;
  published
    property Error: ErrorList  Index (IS_UNQL) read FError write FError;
  end;


  ErrorList = class(TRemotable)
  private
    FErrorCode: WideString;
    FDescription: WideString;
  published
    property ErrorCode:   WideString  Index (IS_UNQL) read FErrorCode write FErrorCode;
    property Description: WideString  Index (IS_UNQL) read FDescription write FDescription;
  end;

  CreditCardPayType = class(TRemotable)
  private
    FCardNumber: WideString;
    FCardName: WideString;
    FCardFromDate: WideString;
    FCardExpiryDate: WideString;
    FCardIssueNo: WideString;
    FCV2: WideString;
    FCardType: CardType;
    FCreditCardFlatNo: WideString;
    FCreditCardHouseNo: WideString;
    FCreditCardAddressLine1: WideString;
    FCreditCardAddressLine2: WideString;
    FCreditCardAddressLine3: WideString;
    FCreditCardAddressLine4: WideString;
    FCreditCardAddressLine5: WideString;
    FCreditCardPostCode: WideString;
    FPaymentDay: WideString;
  published
    property CardNumber:             WideString  Index (IS_UNQL) read FCardNumber write FCardNumber;
    property CardName:               WideString  Index (IS_UNQL) read FCardName write FCardName;
    property CardFromDate:           WideString  Index (IS_UNQL) read FCardFromDate write FCardFromDate;
    property CardExpiryDate:         WideString  Index (IS_UNQL) read FCardExpiryDate write FCardExpiryDate;
    property CardIssueNo:            WideString  Index (IS_UNQL) read FCardIssueNo write FCardIssueNo;
    property CV2:                    WideString  Index (IS_UNQL) read FCV2 write FCV2;
    property CardType:               CardType    Index (IS_UNQL) read FCardType write FCardType;
    property CreditCardFlatNo:       WideString  Index (IS_UNQL) read FCreditCardFlatNo write FCreditCardFlatNo;
    property CreditCardHouseNo:      WideString  Index (IS_UNQL) read FCreditCardHouseNo write FCreditCardHouseNo;
    property CreditCardAddressLine1: WideString  Index (IS_UNQL) read FCreditCardAddressLine1 write FCreditCardAddressLine1;
    property CreditCardAddressLine2: WideString  Index (IS_UNQL) read FCreditCardAddressLine2 write FCreditCardAddressLine2;
    property CreditCardAddressLine3: WideString  Index (IS_UNQL) read FCreditCardAddressLine3 write FCreditCardAddressLine3;
    property CreditCardAddressLine4: WideString  Index (IS_UNQL) read FCreditCardAddressLine4 write FCreditCardAddressLine4;
    property CreditCardAddressLine5: WideString  Index (IS_UNQL) read FCreditCardAddressLine5 write FCreditCardAddressLine5;
    property CreditCardPostCode:     WideString  Index (IS_UNQL) read FCreditCardPostCode write FCreditCardPostCode;
    property PaymentDay:             WideString  Index (IS_UNQL) read FPaymentDay write FPaymentDay;
  end;


  InsertPolicy = class(OneClientCustomerPolicy)
  private
  published
  end;

  Array_Of_Errors = array of Errors;            { "http://www.xyz.com/oneclient-v2/"[GblUbnd] }

  InsertPolicyResponse = class(TRemotable)
  private
    FCustomerRef: WideString;
    FPolicies: PolicyList;
    FErrors: Array_Of_Errors;
    FErrors_Specified: boolean;
    procedure SetErrors(Index: Integer; const AArray_Of_Errors: Array_Of_Errors);
    function  Errors_Specified(Index: Integer): boolean;
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property CustomerRef: WideString       Index (IS_UNQL) read FCustomerRef write FCustomerRef;
    property Policies:    PolicyList       Index (IS_UNQL) read FPolicies write FPolicies;
    property Errors:      Array_Of_Errors  Index (IS_OPTN or IS_UNBD or IS_UNQL) read FErrors write SetErrors stored Errors_Specified;
  end;


#2


续上  

InsertPolicyResponse2 = class(InsertPolicyResponse)
  private
  published
  end;


  // ************************************************************************ //
  // Namespace : http://www.xyz.com/oneclient-v2/
  // soapAction: http://www.xyz.com/oneclient/InsertPolicy
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : document
  // binding   : oneclientSOAP
  // service   : oneclient
  // port      : oneclientSOAP
  // URL       : http://12.12.12.12:3501/oneclient?wsdl
  // ************************************************************************ //
  oneclient = interface(IInvokable)
  ['{350E6DE8-CBD2-4F26-4466-7604F9206B25}']

    // Cannot unwrap: 
    //     - More than one strictly out element was found
    function  InsertPolicy(const InsertPolicy: InsertPolicy): InsertPolicyResponse2; stdcall;
  end;

function Getoneclient(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): oneclient;


implementation
  uses SysUtils;

function Getoneclient(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): oneclient;
const
  defWSDL = 'L:\ABCLtd\Clients\XYZ\HomeServe\oneclient-v2.wsdl';
  defURL  = 'http://12.12.12.12:3501/oneclient?wsdl';
  defSvc  = 'oneclient';
  defPrt  = 'oneclientSOAP';
var
  RIO: THTTPRIO;
begin
  Result := nil;
  if (Addr = '') then
  begin
    if UseWSDL then
      Addr := defWSDL
    else
      Addr := defURL;
  end;
  if HTTPRIO = nil then
    RIO := THTTPRIO.Create(nil)
  else
    RIO := HTTPRIO;
  try
    Result := (RIO as oneclient);
    if UseWSDL then
    begin
      RIO.WSDLLocation := Addr;
      RIO.Service := defSvc;
      RIO.Port := defPrt;
    end else
      RIO.URL := Addr;
  finally
    if (Result = nil) and (HTTPRIO = nil) then
      RIO.Free;
  end;
end;


constructor OneClientCustomerPolicy.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

destructor OneClientCustomerPolicy.Destroy;
var
  I: Integer;
begin
  for I := 0 to Length(FPolicies)-1 do
    FreeAndNil(FPolicies[I]);
  SetLength(FPolicies, 0);
  FreeAndNil(FCustomer);
  FreeAndNil(FAlternativeCustomer);
  inherited Destroy;
end;

destructor Customer.Destroy;
begin
  FreeAndNil(FDateOfBirth);
  inherited Destroy;
end;

destructor Policy.Destroy;
begin
  FreeAndNil(FStartDate);
  FreeAndNil(FPaymentDetail);
  FreeAndNil(FWarrantyDetail);
  inherited Destroy;
end;

destructor PaymentDetails.Destroy;
begin
  FreeAndNil(FCreditCardPayType);
  FreeAndNil(FDirectDebitPayType);
  inherited Destroy;
end;

destructor WarrantyDetail.Destroy;
begin
  FreeAndNil(FInstallationDate);
  inherited Destroy;
end;

destructor Errors.Destroy;
begin
  FreeAndNil(FError);
  inherited Destroy;
end;

constructor InsertPolicyResponse.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

destructor InsertPolicyResponse.Destroy;
var
  I: Integer;
begin
  for I := 0 to Length(FErrors)-1 do
    FreeAndNil(FErrors[I]);
  SetLength(FErrors, 0);
  FreeAndNil(FPolicies);
  inherited Destroy;
end;

procedure InsertPolicyResponse.SetErrors(Index: Integer; const AArray_Of_Errors: Array_Of_Errors);
begin
  FErrors := AArray_Of_Errors;
  FErrors_Specified := True;
end;

function InsertPolicyResponse.Errors_Specified(Index: Integer): boolean;
begin
  Result := FErrors_Specified;
end;

initialization
  InvRegistry.RegisterInterface(TypeInfo(oneclient), 'http://www.xyz.com/oneclient-v2/', 'UTF-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(oneclient), 'http://www.xyz.com/oneclient/InsertPolicy');
  InvRegistry.RegisterInvokeOptions(TypeInfo(oneclient), ioDocument);
  InvRegistry.RegisterInvokeOptions(TypeInfo(oneclient), ioLiteral);
  RemClassRegistry.RegisterXSInfo(TypeInfo(Policies), 'http://www.xyz.com/oneclient-v2/', 'Policies');
  RemClassRegistry.RegisterXSClass(OneClientCustomerPolicy, 'http://www.xyz.com/oneclient-v2/', 'OneClientCustomerPolicy');
  RemClassRegistry.RegisterSerializeOptions(OneClientCustomerPolicy, [xoLiteralParam]);
  RemClassRegistry.RegisterXSInfo(TypeInfo(CustomerType), 'http://www.xyz.com/oneclient-v2/', 'CustomerType');
  RemClassRegistry.RegisterXSInfo(TypeInfo(Country), 'http://www.xyz.com/oneclient-v2/', 'Country');
  RemClassRegistry.RegisterXSInfo(TypeInfo(SpecialNeeds), 'http://www.xyz.com/oneclient-v2/', 'SpecialNeeds');
  RemClassRegistry.RegisterXSClass(Customer, 'http://www.xyz.com/oneclient-v2/', 'Customer');
  RemClassRegistry.RegisterXSInfo(TypeInfo(SalesType), 'http://www.xyz.com/oneclient-v2/', 'SalesType');
  RemClassRegistry.RegisterXSInfo(TypeInfo(PayType), 'http://www.xyz.com/oneclient-v2/', 'PayType');
  RemClassRegistry.RegisterXSClass(Policy, 'http://www.xyz.com/oneclient-v2/', 'Policy');
  RemClassRegistry.RegisterXSClass(PaymentDetails, 'http://www.xyz.com/oneclient-v2/', 'PaymentDetails');
  RemClassRegistry.RegisterXSClass(WarrantyDetail, 'http://www.xyz.com/oneclient-v2/', 'WarrantyDetail');
  RemClassRegistry.RegisterExternalPropName(TypeInfo(WarrantyDetail), 'Type_', 'Type');
  RemClassRegistry.RegisterXSClass(DirectDebitPayType, 'http://www.xyz.com/oneclient-v2/', 'DirectDebitPayType');
  RemClassRegistry.RegisterXSClass(PolicyList, 'http://www.xyz.com/oneclient-v2/', 'PolicyList');
  RemClassRegistry.RegisterXSClass(Errors, 'http://www.xyz.com/oneclient-v2/', 'Errors');
  RemClassRegistry.RegisterXSClass(ErrorList, 'http://www.xyz.com/oneclient-v2/', 'ErrorList');
  RemClassRegistry.RegisterXSInfo(TypeInfo(CardType), 'http://www.xyz.com/oneclient-v2/', 'CardType');
  RemClassRegistry.RegisterExternalPropName(TypeInfo(CardType), 'CCM2', 'CCM');
  RemClassRegistry.RegisterXSClass(CreditCardPayType, 'http://www.xyz.com/oneclient-v2/', 'CreditCardPayType');
  RemClassRegistry.RegisterXSClass(InsertPolicy, 'http://www.xyz.com/oneclient-v2/', 'InsertPolicy');
  RemClassRegistry.RegisterXSInfo(TypeInfo(Array_Of_Errors), 'http://www.xyz.com/oneclient-v2/', 'Array_Of_Errors');
  RemClassRegistry.RegisterXSClass(InsertPolicyResponse, 'http://www.xyz.com/oneclient-v2/', 'InsertPolicyResponse');
  RemClassRegistry.RegisterSerializeOptions(InsertPolicyResponse, [xoLiteralParam]);
  RemClassRegistry.RegisterXSClass(InsertPolicyResponse2, 'http://www.xyz.com/oneclient-v2/', 'InsertPolicyResponse2', 'InsertPolicyResponse');

end.

最好有实例,谢谢大家啦

#3


晕,没人回复哦

#4


看下这个帖子吧
http://topic.csdn.net/u/20080325/17/67fa9173-246d-4d51-a465-13a1db6358b9.html

#5



oneclient = interface(IInvokable)
  ['{350E6DE8-CBD2-4F26-4466-7604F9206B25}']

    // Cannot unwrap:
    //    - More than one strictly out element was found
    function  InsertPolicy(const InsertPolicy: InsertPolicy): InsertPolicyResponse2; stdcall;
  end; 
用HTTPRIO调用这个接口
Var
  p : oneclient ; 
begin
  p := HTTPRIO As oneclient ;
  p.InsertPolicy(InsertPolicy); //InsertPolicy需要创建一个OneClientCustomerPolicy的类,把相关属性添进去就行了
  p:=nil;
end;

#6


非常感谢liangpei2008的回复,我试一下子看看。另外,如果对方的Webservice需要https连接,不知道在Delphi中如何设置认证。比如说对方: https://testws.abc.com:3501/oneclient-v2 同时给你一个用户名与密码。

#7


又碰到新问题了,实例化了一个InsertPolicy, 在添加相关属性的时候,InsertPolicy有一个属性Policies, 它是一个Policy 的数组,如何赋修值。

Policies  = array of Policy;

下面是我的代码:

  FzInsertPolicy :=InsertPolicy.Create;
  FzCustomer := Customer.Create;
  FzAlternativeCustomer := Customer.Create;
  FzPolicy := Policy.Create;
  FzPaymentDetails := PaymentDetails.Create;
  FzCreditCardPayType := CreditCardPayType.Create;
  FzDirectDebitPayType := DirectDebitPayType.Create;
  FzWarrantyDetail := WarrantyDetail.Create;

  with FzInsertPolicy do
  begin
   OneClientChannel := 'FzOneClientChannel';
   TransactionID := 'Fz201002050000001';
   Customer := FzCustomer;
   AlternativeCustomer := FzAlternativeCustomer;
   Policies := 这里怎么写?????;
  end;

  with FzCustomer do
  begin
    CustomerType := d;
    //CompanyName  := '';
    Title  := 'Mr';
    Initials  := 'David';
    Surname  := 'Xu';
    ......
  end;

  with FzAlternativeCustomer do
  begin
     CustomerType := d;
    //CompanyName  := '';
    Title  := 'Mr';
    Initials  := 'David';
    Surname  := 'Xu';
    ......
  end;


  with FzPolicy do
  begin
     MailCode := '';
     AreaCode := '';
     SalePrice := '';
     //StartDate := '';
     //SalesType := '';
     AgentId := '';
     //PayType := '';
     PaymentDetail := FzPaymentDetails;
     WarrantyDetail := FzWarrantyDetail;
  end;

  with FzPaymentDetails do
  begin
    CreditCardPayType := FzCreditCardPayType;
    DirectDebitPayType := FzDirectDebitPayType;
  end;

  with FzCreditCardPayType do
  begin
    CardNumber := '';
    CardName := '';
    ....
  end;

  with FzDirectDebitPayType do
  begin
    AccountNumber := '';
    SortCode := '';
    ....
  end;

  with FzWarrantyDetail do
  begin
   Group := '';
   Manufacturer := '';
   .....
  end;

FzPolicies  是 FzPolicy的一个数组,不知道如何将FzPolicy赋值给FzPolicies????晕啊

#8


数组的问题自己研究解决了,还剩最后的一个问题,就是认证的问题。

它的webservice 是基于https的,对方给了我一个用户名笥密码,怎样才能验证呢?不知道如何操作?

它的wsdl文件中没有找到任何验证的接口。