Link to home
Start Free TrialLog in
Avatar of Marius0188
Marius0188

asked on

Delphi - Webservice Data Submission Problem

Dear Experts,

I need to submit delivery note data to one of our customers.
They have supplied me with a WSDL but I am getting access violations when trying to populate the variables and submitting the data in the structure the depicted via their webservice.

Not sure what I am doing wrong but must admit I am not experienced in webservices.

I will attach the unit for the imported WSDL and then my code just right here:
 
var
    ASGR_IN :SGR_IN;
    ASGR_H :SGRH;
    ASGR_D :SGRD;
    ASGR_T :SGRT;
begin
        ASGR_IN.SGRH.VENDOR_ID := edtVendorID.Text; //ACCESS // 
//VIOLATIONS WHEN TRYING TO POPULATE ANY HEADER OR DETAIL FIELDS
        ASGR_IN.SGRH.DN_NR := qView.FieldByName('DelNote').AsString;
        ASGR_IN.SGRH.DN_DATE := qView.FieldByName('DelDate').AsString;
        ASGR_IN.SGRH.DN_TIME := '';
        ASGR_IN.SGRH.UPLOAD_DATE := '';
        ASGR_IN.SGRH.UPLOAD_TIME := '';
        ASGR_IN.SGRH.POST_DATE := '';
        ASGR_IN.SGRH.POST_TIME := '';
end;

Open in new window


WSDL Unit:
 
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL     : C:\~ My Venture Projects\ Delivery Webservice\~ WSDL\WebService_SupplierGoodsReceipt.xml
//  >Import : C:\~ My Venture Projects\ Delivery Webservice\~ WSDL\WebService_SupplierGoodsReceipt.xml:0
//  >Import : C:\~ My Venture Projects\ Delivery Webservice\~ WSDL\WebService_SupplierGoodsReceipt.xml:1
//  >Import : C:\~ My Venture Projects\ Delivery Webservice\~ WSDL\WebService_SupplierGoodsReceipt.xml:2
// Encoding : utf-8
// Version  : 1.0
// (2011-04-19 12:46:58 PM - - $Rev: 7300 $)
// ************************************************************************ //

unit WebService_SupplierGoodsReceipt;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

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


type

  // ************************************************************************ //
  // The following types, referred to in the WSDL document are not being represented
  // in this file. They are either aliases[@] of other types represented or were referred
  // to but never[!] declared in the document. The types from the latter category
  // typically map to predefined/known XML or Borland types; however, they could also 
  // indicate incorrect WSDL documents that failed to declare or import a schema type.
  // ************************************************************************ //
  // !:string          - "http://www.w3.org/2001/XMLSchema"[Gbl]

  SGRH                 = class;                 { "http://SGReceipt.SGR_IN"[Cplx] }
  ACK                  = class;                 { "http://SGReceipt.ACK"[GblElm] }
  SGRT                 = class;                 { "http://SGReceipt.SGR_IN"[Cplx] }
  SGR_IN               = class;                 { "http://SGReceipt.SGR_IN"[GblElm] }
  SGRD                 = class;                 { "http://SGReceipt.SGR_IN"[Cplx] }



  // ************************************************************************ //
  // XML       : SGRH, <complexType>
  // Namespace : http://SGReceipt.SGR_IN
  // ************************************************************************ //
  SGRH = class(TRemotable)
  private
    FVENDOR_ID: WideString;
    FVENDOR_ID_Specified: boolean;
    FDN_NR: WideString;
    FDN_NR_Specified: boolean;
    FDN_DATE: WideString;
    FDN_DATE_Specified: boolean;
    FDN_TIME: WideString;
    FDN_TIME_Specified: boolean;
    FRECEIVE_DATE: WideString;
    FRECEIVE_DATE_Specified: boolean;
    FRECEIVE_TIME: WideString;
    FRECEIVE_TIME_Specified: boolean;
    FUPLOAD_DATE: WideString;
    FUPLOAD_DATE_Specified: boolean;
    FUPLOAD_TIME: WideString;
    FUPLOAD_TIME_Specified: boolean;
    FPOST_DATE: WideString;
    FPOST_DATE_Specified: boolean;
    FPOST_TIME: WideString;
    FPOST_TIME_Specified: boolean;
    procedure SetVENDOR_ID(Index: Integer; const AWideString: WideString);
    function  VENDOR_ID_Specified(Index: Integer): boolean;
    procedure SetDN_NR(Index: Integer; const AWideString: WideString);
    function  DN_NR_Specified(Index: Integer): boolean;
    procedure SetDN_DATE(Index: Integer; const AWideString: WideString);
    function  DN_DATE_Specified(Index: Integer): boolean;
    procedure SetDN_TIME(Index: Integer; const AWideString: WideString);
    function  DN_TIME_Specified(Index: Integer): boolean;
    procedure SetRECEIVE_DATE(Index: Integer; const AWideString: WideString);
    function  RECEIVE_DATE_Specified(Index: Integer): boolean;
    procedure SetRECEIVE_TIME(Index: Integer; const AWideString: WideString);
    function  RECEIVE_TIME_Specified(Index: Integer): boolean;
    procedure SetUPLOAD_DATE(Index: Integer; const AWideString: WideString);
    function  UPLOAD_DATE_Specified(Index: Integer): boolean;
    procedure SetUPLOAD_TIME(Index: Integer; const AWideString: WideString);
    function  UPLOAD_TIME_Specified(Index: Integer): boolean;
    procedure SetPOST_DATE(Index: Integer; const AWideString: WideString);
    function  POST_DATE_Specified(Index: Integer): boolean;
    procedure SetPOST_TIME(Index: Integer; const AWideString: WideString);
    function  POST_TIME_Specified(Index: Integer): boolean;
  published
    property VENDOR_ID:    WideString  Index (IS_OPTN or IS_UNQL) read FVENDOR_ID write SetVENDOR_ID stored VENDOR_ID_Specified;
    property DN_NR:        WideString  Index (IS_OPTN or IS_UNQL) read FDN_NR write SetDN_NR stored DN_NR_Specified;
    property DN_DATE:      WideString  Index (IS_OPTN or IS_UNQL) read FDN_DATE write SetDN_DATE stored DN_DATE_Specified;
    property DN_TIME:      WideString  Index (IS_OPTN or IS_UNQL) read FDN_TIME write SetDN_TIME stored DN_TIME_Specified;
    property RECEIVE_DATE: WideString  Index (IS_OPTN or IS_UNQL) read FRECEIVE_DATE write SetRECEIVE_DATE stored RECEIVE_DATE_Specified;
    property RECEIVE_TIME: WideString  Index (IS_OPTN or IS_UNQL) read FRECEIVE_TIME write SetRECEIVE_TIME stored RECEIVE_TIME_Specified;
    property UPLOAD_DATE:  WideString  Index (IS_OPTN or IS_UNQL) read FUPLOAD_DATE write SetUPLOAD_DATE stored UPLOAD_DATE_Specified;
    property UPLOAD_TIME:  WideString  Index (IS_OPTN or IS_UNQL) read FUPLOAD_TIME write SetUPLOAD_TIME stored UPLOAD_TIME_Specified;
    property POST_DATE:    WideString  Index (IS_OPTN or IS_UNQL) read FPOST_DATE write SetPOST_DATE stored POST_DATE_Specified;
    property POST_TIME:    WideString  Index (IS_OPTN or IS_UNQL) read FPOST_TIME write SetPOST_TIME stored POST_TIME_Specified;
  end;



  // ************************************************************************ //
  // XML       : ACK, global, <element>
  // Namespace : http://SGReceipt.ACK
  // ************************************************************************ //
  ACK = class(TRemotable)
  private
    FSTATUS_CODE: WideString;
    FSTATUS_CODE_Specified: boolean;
    FREC_DATE: WideString;
    FREC_DATE_Specified: boolean;
    FDN_NR: WideString;
    FDN_NR_Specified: boolean;
    FREC_TIME: WideString;
    FREC_TIME_Specified: boolean;
    procedure SetSTATUS_CODE(Index: Integer; const AWideString: WideString);
    function  STATUS_CODE_Specified(Index: Integer): boolean;
    procedure SetREC_DATE(Index: Integer; const AWideString: WideString);
    function  REC_DATE_Specified(Index: Integer): boolean;
    procedure SetDN_NR(Index: Integer; const AWideString: WideString);
    function  DN_NR_Specified(Index: Integer): boolean;
    procedure SetREC_TIME(Index: Integer; const AWideString: WideString);
    function  REC_TIME_Specified(Index: Integer): boolean;
  published
    property STATUS_CODE: WideString  Index (IS_OPTN or IS_UNQL) read FSTATUS_CODE write SetSTATUS_CODE stored STATUS_CODE_Specified;
    property REC_DATE:    WideString  Index (IS_OPTN or IS_UNQL) read FREC_DATE write SetREC_DATE stored REC_DATE_Specified;
    property DN_NR:       WideString  Index (IS_OPTN or IS_UNQL) read FDN_NR write SetDN_NR stored DN_NR_Specified;
    property REC_TIME:    WideString  Index (IS_OPTN or IS_UNQL) read FREC_TIME write SetREC_TIME stored REC_TIME_Specified;
  end;



  // ************************************************************************ //
  // XML       : SGRT, <complexType>
  // Namespace : http://SGReceipt.SGR_IN
  // ************************************************************************ //
  SGRT = class(TRemotable)
  private
    FNO_OF_LINES: WideString;
    FNO_OF_LINES_Specified: boolean;
    procedure SetNO_OF_LINES(Index: Integer; const AWideString: WideString);
    function  NO_OF_LINES_Specified(Index: Integer): boolean;
  published
    property NO_OF_LINES: WideString  Index (IS_OPTN or IS_UNQL) read FNO_OF_LINES write SetNO_OF_LINES stored NO_OF_LINES_Specified;
  end;

  Array_Of_SGRD = array of SGRD;                { "http://SGReceipt.SGR_IN"[Ubnd] }


  // ************************************************************************ //
  // XML       : SGR_IN, global, <element>
  // Namespace : http://SGReceipt.SGR_IN
  // ************************************************************************ //
  SGR_IN = class(TRemotable)
  private
    FSGRH: SGRH;
    FSGRH_Specified: boolean;
    FSGRD: Array_Of_SGRD;
    FSGRD_Specified: boolean;
    FSGRT: SGRT;
    FSGRT_Specified: boolean;
    procedure SetSGRH(Index: Integer; const ASGRH: SGRH);
    function  SGRH_Specified(Index: Integer): boolean;
    procedure SetSGRD(Index: Integer; const AArray_Of_SGRD: Array_Of_SGRD);
    function  SGRD_Specified(Index: Integer): boolean;
    procedure SetSGRT(Index: Integer; const ASGRT: SGRT);
    function  SGRT_Specified(Index: Integer): boolean;
  public
    destructor Destroy; override;
  published
    property SGRH: SGRH           Index (IS_OPTN or IS_UNQL) read FSGRH write SetSGRH stored SGRH_Specified;
    property SGRD: Array_Of_SGRD  Index (IS_OPTN or IS_UNBD or IS_UNQL) read FSGRD write SetSGRD stored SGRD_Specified;
    property SGRT: SGRT           Index (IS_OPTN or IS_UNQL) read FSGRT write SetSGRT stored SGRT_Specified;
  end;

  Array_Of_string = array of WideString;        { "http://www.w3.org/2001/XMLSchema"[GblUbnd] }


  // ************************************************************************ //
  // XML       : SGRD, <complexType>
  // Namespace : http://SGReceipt.SGR_IN
  // ************************************************************************ //
  SGRD = class(TRemotable)
  private
    FDN_NR: Array_Of_string;
    FDN_NR_Specified: boolean;
    FDN_ITEM: Array_Of_string;
    FDN_ITEM_Specified: boolean;
    FBROADCASTNAME: Array_Of_string;
    FBROADCASTNAME_Specified: boolean;
    FHARI_SEQNO: Array_Of_string;
    FHARI_SEQNO_Specified: boolean;
    FJOBNO: Array_Of_string;
    FJOBNO_Specified: boolean;
    FSYMBOL: Array_Of_string;
    FSYMBOL_Specified: boolean;
    FPART_NUMBER: Array_Of_string;
    FPART_NUMBER_Specified: boolean;
    FQUANTITY: Array_Of_string;
    FQUANTITY_Specified: boolean;
    FSA_NUMBER: Array_Of_string;
    FSA_NUMBER_Specified: boolean;
    FSA_ITEM_NUMBER: Array_Of_string;
    FSA_ITEM_NUMBER_Specified: boolean;
    FGR_QTY: Array_Of_string;
    FGR_QTY_Specified: boolean;
    procedure SetDN_NR(Index: Integer; const AArray_Of_string: Array_Of_string);
    function  DN_NR_Specified(Index: Integer): boolean;
    procedure SetDN_ITEM(Index: Integer; const AArray_Of_string: Array_Of_string);
    function  DN_ITEM_Specified(Index: Integer): boolean;
    procedure SetBROADCASTNAME(Index: Integer; const AArray_Of_string: Array_Of_string);
    function  BROADCASTNAME_Specified(Index: Integer): boolean;
    procedure SetHARI_SEQNO(Index: Integer; const AArray_Of_string: Array_Of_string);
    function  HARI_SEQNO_Specified(Index: Integer): boolean;
    procedure SetJOBNO(Index: Integer; const AArray_Of_string: Array_Of_string);
    function  JOBNO_Specified(Index: Integer): boolean;
    procedure SetSYMBOL(Index: Integer; const AArray_Of_string: Array_Of_string);
    function  SYMBOL_Specified(Index: Integer): boolean;
    procedure SetPART_NUMBER(Index: Integer; const AArray_Of_string: Array_Of_string);
    function  PART_NUMBER_Specified(Index: Integer): boolean;
    procedure SetQUANTITY(Index: Integer; const AArray_Of_string: Array_Of_string);
    function  QUANTITY_Specified(Index: Integer): boolean;
    procedure SetSA_NUMBER(Index: Integer; const AArray_Of_string: Array_Of_string);
    function  SA_NUMBER_Specified(Index: Integer): boolean;
    procedure SetSA_ITEM_NUMBER(Index: Integer; const AArray_Of_string: Array_Of_string);
    function  SA_ITEM_NUMBER_Specified(Index: Integer): boolean;
    procedure SetGR_QTY(Index: Integer; const AArray_Of_string: Array_Of_string);
    function  GR_QTY_Specified(Index: Integer): boolean;
  published
    property DN_NR:          Array_Of_string  Index (IS_OPTN or IS_UNBD or IS_UNQL) read FDN_NR write SetDN_NR stored DN_NR_Specified;
    property DN_ITEM:        Array_Of_string  Index (IS_OPTN or IS_UNBD or IS_UNQL) read FDN_ITEM write SetDN_ITEM stored DN_ITEM_Specified;
    property BROADCASTNAME:  Array_Of_string  Index (IS_OPTN or IS_UNBD or IS_UNQL) read FBROADCASTNAME write SetBROADCASTNAME stored BROADCASTNAME_Specified;
    property HARI_SEQNO:     Array_Of_string  Index (IS_OPTN or IS_UNBD or IS_UNQL) read FHARI_SEQNO write SetHARI_SEQNO stored HARI_SEQNO_Specified;
    property JOBNO:          Array_Of_string  Index (IS_OPTN or IS_UNBD or IS_UNQL) read FJOBNO write SetJOBNO stored JOBNO_Specified;
    property SYMBOL:         Array_Of_string  Index (IS_OPTN or IS_UNBD or IS_UNQL) read FSYMBOL write SetSYMBOL stored SYMBOL_Specified;
    property PART_NUMBER:    Array_Of_string  Index (IS_OPTN or IS_UNBD or IS_UNQL) read FPART_NUMBER write SetPART_NUMBER stored PART_NUMBER_Specified;
    property QUANTITY:       Array_Of_string  Index (IS_OPTN or IS_UNBD or IS_UNQL) read FQUANTITY write SetQUANTITY stored QUANTITY_Specified;
    property SA_NUMBER:      Array_Of_string  Index (IS_OPTN or IS_UNBD or IS_UNQL) read FSA_NUMBER write SetSA_NUMBER stored SA_NUMBER_Specified;
    property SA_ITEM_NUMBER: Array_Of_string  Index (IS_OPTN or IS_UNBD or IS_UNQL) read FSA_ITEM_NUMBER write SetSA_ITEM_NUMBER stored SA_ITEM_NUMBER_Specified;
    property GR_QTY:         Array_Of_string  Index (IS_OPTN or IS_UNBD or IS_UNQL) read FGR_QTY write SetGR_QTY stored GR_QTY_Specified;
  end;


  // ************************************************************************ //
  // Namespace : http://customer.co.za/
  // soapAction: http:// customer.co.za/WebService_SupplierGoodsReceipt/Rec_SGR_IN
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : document
  // binding   : WebService_SupplierGoodsReceiptSoap
  // service   : WebService_SupplierGoodsReceipt
  // port      : WebService_SupplierGoodsReceiptSoap
  // URL       : http://127.0.0.1/SupplierGoodsReceipt_Proxy/WebService_SupplierGoodsReceipt.asmx
  // ************************************************************************ //
  WebService_SupplierGoodsReceiptSoap = interface(IInvokable)
  ['{F6237CAC-1D0F-035A-9500-B9777D03E2A2}']
    function  Rec_SGR_IN(const SGR_IN: SGR_IN): ACK; stdcall;
  end;

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


implementation
  uses SysUtils;

function GetWebService_SupplierGoodsReceiptSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): WebService_SupplierGoodsReceiptSoap;
const
  defWSDL = 'C:\~ My Venture Projects\Customer Delivery Webservice\~ WSDL\WebService_SupplierGoodsReceipt.xml';
  defURL  = 'http://127.0.0.1/SupplierGoodsReceipt_Proxy/WebService_SupplierGoodsReceipt.asmx';
  defSvc  = 'WebService_SupplierGoodsReceipt';
  defPrt  = 'WebService_SupplierGoodsReceiptSoap';
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 WebService_SupplierGoodsReceiptSoap);
    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;


procedure SGRH.SetVENDOR_ID(Index: Integer; const AWideString: WideString);
begin
  FVENDOR_ID := AWideString;
  FVENDOR_ID_Specified := True;
end;

function SGRH.VENDOR_ID_Specified(Index: Integer): boolean;
begin
  Result := FVENDOR_ID_Specified;
end;

procedure SGRH.SetDN_NR(Index: Integer; const AWideString: WideString);
begin
  FDN_NR := AWideString;
  FDN_NR_Specified := True;
end;

function SGRH.DN_NR_Specified(Index: Integer): boolean;
begin
  Result := FDN_NR_Specified;
end;

procedure SGRH.SetDN_DATE(Index: Integer; const AWideString: WideString);
begin
  FDN_DATE := AWideString;
  FDN_DATE_Specified := True;
end;

function SGRH.DN_DATE_Specified(Index: Integer): boolean;
begin
  Result := FDN_DATE_Specified;
end;

procedure SGRH.SetDN_TIME(Index: Integer; const AWideString: WideString);
begin
  FDN_TIME := AWideString;
  FDN_TIME_Specified := True;
end;

function SGRH.DN_TIME_Specified(Index: Integer): boolean;
begin
  Result := FDN_TIME_Specified;
end;

procedure SGRH.SetRECEIVE_DATE(Index: Integer; const AWideString: WideString);
begin
  FRECEIVE_DATE := AWideString;
  FRECEIVE_DATE_Specified := True;
end;

function SGRH.RECEIVE_DATE_Specified(Index: Integer): boolean;
begin
  Result := FRECEIVE_DATE_Specified;
end;

procedure SGRH.SetRECEIVE_TIME(Index: Integer; const AWideString: WideString);
begin
  FRECEIVE_TIME := AWideString;
  FRECEIVE_TIME_Specified := True;
end;

function SGRH.RECEIVE_TIME_Specified(Index: Integer): boolean;
begin
  Result := FRECEIVE_TIME_Specified;
end;

procedure SGRH.SetUPLOAD_DATE(Index: Integer; const AWideString: WideString);
begin
  FUPLOAD_DATE := AWideString;
  FUPLOAD_DATE_Specified := True;
end;

function SGRH.UPLOAD_DATE_Specified(Index: Integer): boolean;
begin
  Result := FUPLOAD_DATE_Specified;
end;

procedure SGRH.SetUPLOAD_TIME(Index: Integer; const AWideString: WideString);
begin
  FUPLOAD_TIME := AWideString;
  FUPLOAD_TIME_Specified := True;
end;

function SGRH.UPLOAD_TIME_Specified(Index: Integer): boolean;
begin
  Result := FUPLOAD_TIME_Specified;
end;

procedure SGRH.SetPOST_DATE(Index: Integer; const AWideString: WideString);
begin
  FPOST_DATE := AWideString;
  FPOST_DATE_Specified := True;
end;

function SGRH.POST_DATE_Specified(Index: Integer): boolean;
begin
  Result := FPOST_DATE_Specified;
end;

procedure SGRH.SetPOST_TIME(Index: Integer; const AWideString: WideString);
begin
  FPOST_TIME := AWideString;
  FPOST_TIME_Specified := True;
end;

function SGRH.POST_TIME_Specified(Index: Integer): boolean;
begin
  Result := FPOST_TIME_Specified;
end;

procedure ACK.SetSTATUS_CODE(Index: Integer; const AWideString: WideString);
begin
  FSTATUS_CODE := AWideString;
  FSTATUS_CODE_Specified := True;
end;

function ACK.STATUS_CODE_Specified(Index: Integer): boolean;
begin
  Result := FSTATUS_CODE_Specified;
end;

procedure ACK.SetREC_DATE(Index: Integer; const AWideString: WideString);
begin
  FREC_DATE := AWideString;
  FREC_DATE_Specified := True;
end;

function ACK.REC_DATE_Specified(Index: Integer): boolean;
begin
  Result := FREC_DATE_Specified;
end;

procedure ACK.SetDN_NR(Index: Integer; const AWideString: WideString);
begin
  FDN_NR := AWideString;
  FDN_NR_Specified := True;
end;

function ACK.DN_NR_Specified(Index: Integer): boolean;
begin
  Result := FDN_NR_Specified;
end;

procedure ACK.SetREC_TIME(Index: Integer; const AWideString: WideString);
begin
  FREC_TIME := AWideString;
  FREC_TIME_Specified := True;
end;

function ACK.REC_TIME_Specified(Index: Integer): boolean;
begin
  Result := FREC_TIME_Specified;
end;

procedure SGRT.SetNO_OF_LINES(Index: Integer; const AWideString: WideString);
begin
  FNO_OF_LINES := AWideString;
  FNO_OF_LINES_Specified := True;
end;

function SGRT.NO_OF_LINES_Specified(Index: Integer): boolean;
begin
  Result := FNO_OF_LINES_Specified;
end;

destructor SGR_IN.Destroy;
var
  I: Integer;
begin
  for I := 0 to Length(FSGRD)-1 do
    FreeAndNil(FSGRD[I]);
  SetLength(FSGRD, 0);
  FreeAndNil(FSGRH);
  FreeAndNil(FSGRT);
  inherited Destroy;
end;

procedure SGR_IN.SetSGRH(Index: Integer; const ASGRH: SGRH);
begin
  FSGRH := ASGRH;
  FSGRH_Specified := True;
end;

function SGR_IN.SGRH_Specified(Index: Integer): boolean;
begin
  Result := FSGRH_Specified;
end;

procedure SGR_IN.SetSGRD(Index: Integer; const AArray_Of_SGRD: Array_Of_SGRD);
begin
  FSGRD := AArray_Of_SGRD;
  FSGRD_Specified := True;
end;

function SGR_IN.SGRD_Specified(Index: Integer): boolean;
begin
  Result := FSGRD_Specified;
end;

procedure SGR_IN.SetSGRT(Index: Integer; const ASGRT: SGRT);
begin
  FSGRT := ASGRT;
  FSGRT_Specified := True;
end;

function SGR_IN.SGRT_Specified(Index: Integer): boolean;
begin
  Result := FSGRT_Specified;
end;

procedure SGRD.SetDN_NR(Index: Integer; const AArray_Of_string: Array_Of_string);
begin
  FDN_NR := AArray_Of_string;
  FDN_NR_Specified := True;
end;

function SGRD.DN_NR_Specified(Index: Integer): boolean;
begin
  Result := FDN_NR_Specified;
end;

procedure SGRD.SetDN_ITEM(Index: Integer; const AArray_Of_string: Array_Of_string);
begin
  FDN_ITEM := AArray_Of_string;
  FDN_ITEM_Specified := True;
end;

function SGRD.DN_ITEM_Specified(Index: Integer): boolean;
begin
  Result := FDN_ITEM_Specified;
end;

procedure SGRD.SetBROADCASTNAME(Index: Integer; const AArray_Of_string: Array_Of_string);
begin
  FBROADCASTNAME := AArray_Of_string;
  FBROADCASTNAME_Specified := True;
end;

function SGRD.BROADCASTNAME_Specified(Index: Integer): boolean;
begin
  Result := FBROADCASTNAME_Specified;
end;

procedure SGRD.SetHARI_SEQNO(Index: Integer; const AArray_Of_string: Array_Of_string);
begin
  FHARI_SEQNO := AArray_Of_string;
  FHARI_SEQNO_Specified := True;
end;

function SGRD.HARI_SEQNO_Specified(Index: Integer): boolean;
begin
  Result := FHARI_SEQNO_Specified;
end;

procedure SGRD.SetJOBNO(Index: Integer; const AArray_Of_string: Array_Of_string);
begin
  FJOBNO := AArray_Of_string;
  FJOBNO_Specified := True;
end;

function SGRD.JOBNO_Specified(Index: Integer): boolean;
begin
  Result := FJOBNO_Specified;
end;

procedure SGRD.SetSYMBOL(Index: Integer; const AArray_Of_string: Array_Of_string);
begin
  FSYMBOL := AArray_Of_string;
  FSYMBOL_Specified := True;
end;

function SGRD.SYMBOL_Specified(Index: Integer): boolean;
begin
  Result := FSYMBOL_Specified;
end;

procedure SGRD.SetPART_NUMBER(Index: Integer; const AArray_Of_string: Array_Of_string);
begin
  FPART_NUMBER := AArray_Of_string;
  FPART_NUMBER_Specified := True;
end;

function SGRD.PART_NUMBER_Specified(Index: Integer): boolean;
begin
  Result := FPART_NUMBER_Specified;
end;

procedure SGRD.SetQUANTITY(Index: Integer; const AArray_Of_string: Array_Of_string);
begin
  FQUANTITY := AArray_Of_string;
  FQUANTITY_Specified := True;
end;

function SGRD.QUANTITY_Specified(Index: Integer): boolean;
begin
  Result := FQUANTITY_Specified;
end;

procedure SGRD.SetSA_NUMBER(Index: Integer; const AArray_Of_string: Array_Of_string);
begin
  FSA_NUMBER := AArray_Of_string;
  FSA_NUMBER_Specified := True;
end;

function SGRD.SA_NUMBER_Specified(Index: Integer): boolean;
begin
  Result := FSA_NUMBER_Specified;
end;

procedure SGRD.SetSA_ITEM_NUMBER(Index: Integer; const AArray_Of_string: Array_Of_string);
begin
  FSA_ITEM_NUMBER := AArray_Of_string;
  FSA_ITEM_NUMBER_Specified := True;
end;

function SGRD.SA_ITEM_NUMBER_Specified(Index: Integer): boolean;
begin
  Result := FSA_ITEM_NUMBER_Specified;
end;

procedure SGRD.SetGR_QTY(Index: Integer; const AArray_Of_string: Array_Of_string);
begin
  FGR_QTY := AArray_Of_string;
  FGR_QTY_Specified := True;
end;

function SGRD.GR_QTY_Specified(Index: Integer): boolean;
begin
  Result := FGR_QTY_Specified;
end;

initialization
  InvRegistry.RegisterInterface(TypeInfo(WebService_SupplierGoodsReceiptSoap), 'http://customer.co.za/', 'utf-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(WebService_SupplierGoodsReceiptSoap), 'http://customer.co.za/WebService_SupplierGoodsReceipt/Rec_SGR_IN');
  InvRegistry.RegisterInvokeOptions(TypeInfo(WebService_SupplierGoodsReceiptSoap), ioDocument);
  RemClassRegistry.RegisterXSClass(SGRH, 'http://SupplierGoodsReceipt.SGR_IN', 'SGRH');
  RemClassRegistry.RegisterXSClass(ACK, 'http://SupplierGoodsReceipt.ACK', 'ACK');
  RemClassRegistry.RegisterXSClass(SGRT, 'http://SupplierGoodsReceipt.SGR_IN', 'SGRT');
  RemClassRegistry.RegisterXSInfo(TypeInfo(Array_Of_SGRD), 'http://SupplierGoodsReceipt.SGR_IN', 'Array_Of_SGRD');
  RemClassRegistry.RegisterXSClass(SGR_IN, 'http://SupplierGoodsReceipt.SGR_IN', 'SGR_IN');
  RemClassRegistry.RegisterXSInfo(TypeInfo(Array_Of_string), 'http://www.w3.org/2001/XMLSchema', 'Array_Of_string');
  RemClassRegistry.RegisterXSClass(SGRD, 'http://SupplierGoodsReceipt.SGR_IN', 'SGRD');

end.

Open in new window


Please show me how should I talk to this webservice and submit the required data.
Thanks a lot.
Avatar of samenglish
samenglish
Flag of Australia image

uses WebService_SupplierGoodsReceipt;

procedure DoSomethingWithWebService;
var
  service1: WebService_SupplierGoodsReceiptSoap;
  mySGR_IN: SGR_IN;
  myACK: ACK;
begin

  try
    service1 := WebService_SupplierGoodsReceipt.GetWebService_SupplierGoodsReceiptSoap;

    // now just type service1 and then "." and let the autocomplete/intellisense show you
    // all the published members that are available for your use (proc, func, types etc)

    // example (not tested - not 100% sure)

   // populate your input parameter here
   mySGR_IN := blahblah;
   myACK := service1.Rec_SGR_IN(mySGR_IN)

  finally
    service1 := nil;
  end;

end;

// hope it helps, Good luck.
Avatar of Marius0188
Marius0188

ASKER

Thanks for the reply.

SGR_IN has several published members / properties for example:

        mySGR_IN.SGRH.VENDOR_ID
        mySGR_IN.SGRH.DN_NR
        mySGR_IN.SGRH.DN_DATE
        mySGR_IN.SGRH.DN_TIME
        mySGR_IN.SGRH.UPLOAD_DATE
        mySGR_IN.SGRH.UPLOAD_TIME
        mySGR_IN.SGRH.POST_DATE
        mySGR_IN.SGRH.POST_TIME

And when I am trying to assign a value to for example, the first one:
        mySGR_IN.SGRH.VENDOR_ID := "VEN001";
I receive an Access Violation error.

Why this?
These properties need to be assigned.

Please advise.


Ok now I am getting this error:

DelphiWebServiceTimeout.jpg
I am now using the RIO component with following code:

procedure TfrmMain.Button1Click(Sender: TObject);
begin
  Try
    if not FileExists(ExtractFileDir(Application.ExeName) + '\~ WSDL\WebService_SupplierGoodsReceipt.xml') then
    begin
      MessageDLG('WSDL File not found!', mtError, [mbOk], 0);
      Exit;
    end;
    RIO.WSDLLocation := ExtractFileDir(Application.ExeName) + '\~ WSDL\WebService_SupplierGoodsReceipt.xml';
    ASGR_IN.SGRH.VENDOR_ID := 'Test Garbage';

    ShowMessage('Get: ResultCode');
//    ResultCode := WebService.Rec_SGR_IN(ASGR_IN);
    ResultCode := (RIO AS WebService_SupplierGoodsReceiptSoap).Rec_SGR_IN(ASGR_IN);
    ShowMessage('Result: ' + ResultCode.STATUS_CODE);
  Finally
  End;
end;

And then I receive the error in screenshot attached, please advise:
DelphiWebServiceEndUrl.jpg
If you get AVs when trying to assign values to properties of an object type then you need to create an instance of that object first.

Apart from that, you're totally on the wrong track checking for the existence of you wsdl at runtime. The wsdl is used by the delphi wsdl importer (at design-time) to create a proxy class (in this case it's in pascal) so the rest of your app can access the methods described in the wsdl (now also in the delphi proxy class). Your app only needs the proxy class WebService_SupplierGoodsReceipt.pas (not xml). You don't need the Rio stuff, that's all been done for you in the proxy class (ie. your wsdl unit).

try...

uses WebService_SupplierGoodsReceipt;

procedure DoSomethingWithWebService;
var
  service1: WebService_SupplierGoodsReceiptSoap;
  mySGR_IN: SGR_IN;
  myACK: ACK;
begin

  mySGR_IN := SGR_IN.Create(nil);

  try
    service1 := WebService_SupplierGoodsReceipt.GetWebService_SupplierGoodsReceiptSoap;
    mySGR_IN.SGRH.VENDOR_ID := "VEN001"; // shouldn't AV if the above create worked
    myACK := service1.Rec_SGR_IN(mySGR_IN)
  finally
    service1 := nil;
    mySGR_IN.Free;
  end;

end;
Ok I've reverted back to your example code.
Creating instances on form create.

But I still get the error message, time out error.
Is the problem on my side or on the webservice server's side?

Please please advise as this is urgent project.
Thanks :)

  WebService := WebService_SupplierGoodsReceipt.GetWebService_SupplierGoodsReceiptSoap;
  Try
    ASGR_IN.SGRH.VENDOR_ID := 'Test Garbage';
    ShowMessage('Get: ResultCode');
    ResultCode := WebService.Rec_SGR_IN(ASGR_IN);
    ShowMessage('Result: ' + ResultCode.STATUS_CODE);
  Finally
     WebService := nil;
  End;

DelphiWebServiceTimeout.jpg
ASKER CERTIFIED SOLUTION
Avatar of samenglish
samenglish
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial