?
Solved

Delphi 2010 - consuming a web service

Posted on 2010-01-07
5
Medium Priority
?
2,821 Views
Last Modified: 2013-11-23
Hello,

I am using Delphi 2010 and imported a webservice.  See the attached code.  (Note I have only included the interface.)

 The question is how do I call any of the methods.... everything seems to have changed since Delphi 6!!

Can anyone give me an axample on how to call GetVersion?


unit gnasher.wspoppis;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

const
  IS_OPTN = $0001;
  IS_REF  = $0080;


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 Embarcadero 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]
  // !:boolean         - "http://www.w3.org/2001/XMLSchema"[Gbl]
  // !:int             - "http://www.w3.org/2001/XMLSchema"[Gbl]
  // !:long            - "http://www.w3.org/2001/XMLSchema"[Gbl]

  GetVersion           = class;                 { "http://Gnasher.Poppis.org/"[Lit][GblElm] }
  GetVersionResponse   = class;                 { "http://Gnasher.Poppis.org/"[Lit][GblElm] }
  HelloWorld           = class;                 { "http://Gnasher.Poppis.org/"[Lit][GblElm] }
  HelloWorldResponse   = class;                 { "http://Gnasher.Poppis.org/"[Lit][GblElm] }
  GetPerson            = class;                 { "http://Gnasher.Poppis.org/"[Lit][GblElm] }
  GetPersonResponse    = class;                 { "http://Gnasher.Poppis.org/"[Lit][GblElm] }
  HeaderInfo           = class;                 { "http://www.tietoenator.com/HCW/PopulationManager"[GblCplx] }
  HeaderInfo2          = class;                 { "http://www.tietoenator.com/HCW/PopulationManager"[GblElm] }
  HeaderErrorInfo      = class;                 { "http://www.tietoenator.com/HCW/PopulationManager"[GblCplx] }
  HeaderErrorInfo2     = class;                 { "http://www.tietoenator.com/HCW/PopulationManager"[GblElm] }

  {$SCOPEDENUMS ON}
  { "http://www.tietoenator.com/HCW/PopulationManager"[GblSmpl] }
  EnumTEHCHeaderSeverity = (None, Critical, Warning, Information);

  {$SCOPEDENUMS OFF}



  // ************************************************************************ //
  // XML       : GetVersion, global, <element>
  // Namespace : http://Gnasher.Poppis.org/
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  GetVersion = class(TRemotable)
  private
  public
    constructor Create; override;
  published
  end;



  // ************************************************************************ //
  // XML       : GetVersionResponse, global, <element>
  // Namespace : http://Gnasher.Poppis.org/
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  GetVersionResponse = class(TRemotable)
  private
    FGetVersionResult: string;
    FGetVersionResult_Specified: boolean;
    procedure SetGetVersionResult(Index: Integer; const Astring: string);
    function  GetVersionResult_Specified(Index: Integer): boolean;
  public
    constructor Create; override;
  published
    property GetVersionResult: string  Index (IS_OPTN) read FGetVersionResult write SetGetVersionResult stored GetVersionResult_Specified;
  end;



  // ************************************************************************ //
  // XML       : HelloWorld, global, <element>
  // Namespace : http://Gnasher.Poppis.org/
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  HelloWorld = class(TRemotable)
  private
  public
    constructor Create; override;
  published
  end;



  // ************************************************************************ //
  // XML       : HelloWorldResponse, global, <element>
  // Namespace : http://Gnasher.Poppis.org/
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  HelloWorldResponse = class(TRemotable)
  private
    FHelloWorldResult: string;
    FHelloWorldResult_Specified: boolean;
    procedure SetHelloWorldResult(Index: Integer; const Astring: string);
    function  HelloWorldResult_Specified(Index: Integer): boolean;
  public
    constructor Create; override;
  published
    property HelloWorldResult: string  Index (IS_OPTN) read FHelloWorldResult write SetHelloWorldResult stored HelloWorldResult_Specified;
  end;



  // ************************************************************************ //
  // XML       : GetPerson, global, <element>
  // Namespace : http://Gnasher.Poppis.org/
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  GetPerson = class(TRemotable)
  private
    FUserid: string;
    FUserid_Specified: boolean;
    FPassword: string;
    FPassword_Specified: boolean;
    FPID: string;
    FPID_Specified: boolean;
    FotherArchives: Boolean;
    procedure SetUserid(Index: Integer; const Astring: string);
    function  Userid_Specified(Index: Integer): boolean;
    procedure SetPassword(Index: Integer; const Astring: string);
    function  Password_Specified(Index: Integer): boolean;
    procedure SetPID(Index: Integer; const Astring: string);
    function  PID_Specified(Index: Integer): boolean;
  public
    constructor Create; override;
  published
    property Userid:        string   Index (IS_OPTN) read FUserid write SetUserid stored Userid_Specified;
    property Password:      string   Index (IS_OPTN) read FPassword write SetPassword stored Password_Specified;
    property PID:           string   Index (IS_OPTN) read FPID write SetPID stored PID_Specified;
    property otherArchives: Boolean  read FotherArchives write FotherArchives;
  end;



  // ************************************************************************ //
  // XML       : GetPersonResponse, global, <element>
  // Namespace : http://Gnasher.Poppis.org/
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  GetPersonResponse = class(TRemotable)
  private
    FGetPersonResult: string;
    FGetPersonResult_Specified: boolean;
    FHeaderInfo: HeaderInfo2;
    FHeaderInfo_Specified: boolean;
    FHeaderErrorInfo: HeaderErrorInfo2;
    FHeaderErrorInfo_Specified: boolean;
    procedure SetGetPersonResult(Index: Integer; const Astring: string);
    function  GetPersonResult_Specified(Index: Integer): boolean;
    procedure SetHeaderInfo(Index: Integer; const AHeaderInfo2: HeaderInfo2);
    function  HeaderInfo_Specified(Index: Integer): boolean;
    procedure SetHeaderErrorInfo(Index: Integer; const AHeaderErrorInfo2: HeaderErrorInfo2);
    function  HeaderErrorInfo_Specified(Index: Integer): boolean;
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property GetPersonResult: string            Index (IS_OPTN) read FGetPersonResult write SetGetPersonResult stored GetPersonResult_Specified;
    property HeaderInfo:      HeaderInfo2       Index (IS_OPTN or IS_REF) read FHeaderInfo write SetHeaderInfo stored HeaderInfo_Specified;
    property HeaderErrorInfo: HeaderErrorInfo2  Index (IS_OPTN or IS_REF) read FHeaderErrorInfo write SetHeaderErrorInfo stored HeaderErrorInfo_Specified;
  end;



  // ************************************************************************ //
  // XML       : HeaderInfo, global, <complexType>
  // Namespace : http://www.tietoenator.com/HCW/PopulationManager
  // ************************************************************************ //
  HeaderInfo = class(TRemotable)
  private
    FRowsCount: Integer;
    FMaxRows: Integer;
    FSourceName: string;
    FSourceName_Specified: boolean;
    procedure SetSourceName(Index: Integer; const Astring: string);
    function  SourceName_Specified(Index: Integer): boolean;
  published
    property RowsCount:  Integer  read FRowsCount write FRowsCount;
    property MaxRows:    Integer  read FMaxRows write FMaxRows;
    property SourceName: string   Index (IS_OPTN) read FSourceName write SetSourceName stored SourceName_Specified;
  end;



  // ************************************************************************ //
  // XML       : HeaderInfo, global, <element>
  // Namespace : http://www.tietoenator.com/HCW/PopulationManager
  // ************************************************************************ //
  HeaderInfo2 = class(HeaderInfo)
  private
  published
  end;



  // ************************************************************************ //
  // XML       : HeaderErrorInfo, global, <complexType>
  // Namespace : http://www.tietoenator.com/HCW/PopulationManager
  // ************************************************************************ //
  HeaderErrorInfo = class(TRemotable)
  private
    FFunctionName: string;
    FFunctionName_Specified: boolean;
    FSeverity: EnumTEHCHeaderSeverity;
    FErrorType: string;
    FErrorType_Specified: boolean;
    FModuleName: string;
    FModuleName_Specified: boolean;
    FDescription: string;
    FDescription_Specified: boolean;
    FCode: Int64;
    procedure SetFunctionName(Index: Integer; const Astring: string);
    function  FunctionName_Specified(Index: Integer): boolean;
    procedure SetErrorType(Index: Integer; const Astring: string);
    function  ErrorType_Specified(Index: Integer): boolean;
    procedure SetModuleName(Index: Integer; const Astring: string);
    function  ModuleName_Specified(Index: Integer): boolean;
    procedure SetDescription(Index: Integer; const Astring: string);
    function  Description_Specified(Index: Integer): boolean;
  published
    property FunctionName: string                  Index (IS_OPTN) read FFunctionName write SetFunctionName stored FunctionName_Specified;
    property Severity:     EnumTEHCHeaderSeverity  read FSeverity write FSeverity;
    property ErrorType:    string                  Index (IS_OPTN) read FErrorType write SetErrorType stored ErrorType_Specified;
    property ModuleName:   string                  Index (IS_OPTN) read FModuleName write SetModuleName stored ModuleName_Specified;
    property Description:  string                  Index (IS_OPTN) read FDescription write SetDescription stored Description_Specified;
    property Code:         Int64                   read FCode write FCode;
  end;



  // ************************************************************************ //
  // XML       : HeaderErrorInfo, global, <element>
  // Namespace : http://www.tietoenator.com/HCW/PopulationManager
  // ************************************************************************ //
  HeaderErrorInfo2 = class(HeaderErrorInfo)
  private
  published
  end;


  // ************************************************************************ //
  // Namespace : http://Gnasher.Poppis.org/
  // soapAction: http://Gnasher.Poppis.org/%operationName%
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : document
  // binding   : serviceSoap12
  // service   : service
  // port      : serviceSoap12
  // URL       : https://www.eyenetreg.se/gnasher.wspoppis/gnasher.wspoppis.asmx
  // ************************************************************************ //
  serviceSoap = interface(IInvokable)
  ['{FCC6D8CB-730F-EBD0-3AE1-6C47631A8069}']
    function  GetVersion(const parameters: GetVersion): GetVersionResponse; stdcall;
    function  HelloWorld(const parameters: HelloWorld): HelloWorldResponse; stdcall;

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

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

Open in new window

0
Comment
Question by:soozh
  • 3
  • 2
5 Comments
 
LVL 2

Expert Comment

by:gurkal
ID: 26198605
use gnasher.wspoppis

procedure TForm1.Button1Click(Sender: TObject);
begin
     ShowMessage(GetserviceSoap.GetVersion(nil).GetVersionResult);
end;
0
 

Author Comment

by:soozh
ID: 26198757
Hello,

Yep that worked... so can you explain what the "nil" is for? and why is it not possible to call

ShowMessage( GetserviceSoap.GetVersion() );
0
 
LVL 2

Accepted Solution

by:
gurkal earned 2000 total points
ID: 26198879
GetserviceSoap expects a parameter as GetVersion type. But i think it's not using
you can send it like this
procedure TForm1.Button1Click(Sender: TObject);
var
   GetVerisonParam:GetVersion;
begin
     GetVerisonParam:=GetVersion.Create;
     try
        ShowMessage(GetserviceSoap.GetVersion(GetVerisonParam).GetVersionResult);
     finally
      GetVerisonParam.Free;
     end;
end;
0
 

Author Comment

by:soozh
ID: 26198916
OK.

Then how would I call GetPerson which requires the parameters PID and otherArchives.  It also returns a complex result in the form of GetPersonResponse.

0
 

Author Closing Comment

by:soozh
ID: 31673927
I worked out the rest myself...
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question