Use Delphi to write Web Service (instance) (continued, with Delphi to write the client)

Source: Internet
Author: User
Tags integer soap web services wsdl

Following last night's article: http://blog.csdn.net/yxf/archive/2006/09/28/1303281.aspx, write a method that uses Delphi to write a client. Also called last night's libss.dll.

1. Create a new console application, called Sampleservice.invoker.

2. File->new->other, Web services/wsdl Importer, fill in the location of the WSDL File or URL http://localhost/MyServices/ Sampleservice/libss.dll/wsdl/isampleservice, then click Finish, then click Finish, then save the generated unit to Icomplexoperatorsunit.pas.

The following is the contents of the generated cell:

//   ************************************************************************   //
The types declared in this file were generated from data read from the
WSDL File described below:
Wsdl:http://Localhost/myservices/sampleservice/libss.dll/wsdl/isampleservice
Encoding:utf-8
version:1.0
(2006-9-29 10:03:31-16.03.2006)
//   ************************************************************************   //

Unit isampleserviceunit;

Interface

Uses Invokeregistry, soaphttpclient, Types, Xsbuiltins;

Type

//   ************************************************************************   //
The following types, referred to in the WSDL document is not being represented
In the This file. They is 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.
//   ************************************************************************   //
!: Double-"Http://www.w3.org/2001/XMLSchema"
!: INT-"Http://www.w3.org/2001/XMLSchema"

[WARNINGS] **************************************************************//
Unable to sort type ' tclassa ' due to circular reference!
//   ************************************************************************   //

Tcomplex = class; {"Urn:sampleserviceintf"}
Textradata = class; {"Urn:sampleserviceintf"}
Tloopable = class; {"Urn:sampleserviceintf"}
Tclassa = class; {"Urn:sampleserviceintf"}
TCLASSB = class; {"Urn:sampleserviceintf"}



//   ************************************************************************   //
Namespace:urn:SampleServiceIntf
//   ************************************************************************   //
Tcomplex = Class (Tremotable)
Private
fr:double;
fi:double;
Published
Property R:double Read Fr write Fr;
Property i:double read fi write fi;
End;



//   ************************************************************************   //
Namespace:urn:SampleServiceIntf
//   ************************************************************************   //
Textradata = Class (Tremotable)
Private
Fx:integer;
Published
Property X:integer read FX write FX;
End;



//   ************************************************************************   //
Namespace:urn:SampleServiceIntf
//   ************************************************************************   //
Tloopable = Class (Tremotable)
Private
Fdata:textradata;
fnext:tloopable;
Public
destructor Destroy; Override
Published
Property Data:textradata read FData write FData;
Property next:tloopable read Fnext write Fnext;
End;



//   ************************************************************************   //
Namespace:urn:SampleServiceIntf
//   ************************************************************************   //
Tclassa = Class (Tremotable)
Private
FREF:TCLASSB;
Public
destructor Destroy; Override
Published
Property REF:TCLASSB read Fref write fref;
End;



//   ************************************************************************   //
Namespace:urn:SampleServiceIntf
//   ************************************************************************   //
TCLASSB = Class (Tremotable)
Private
Fref:tclassa;
Public
destructor Destroy; Override
Published
Property Ref:tclassa read Fref write fref;
End;


//   ************************************************************************   //
Namespace:urn:sampleserviceintf-isampleservice
Soapaction:urn:sampleserviceintf-isampleservice#%operationname%
Transport:http://Schemas.xmlsoap.org/soap/http
Style:rpc
Binding:isampleservicebinding
Service:isampleserviceservice
Port:isampleserviceport
Url:http://Localhost/myservices/sampleservice/libss.dll/soap/isampleservice
//   ************************************************************************   //
Isampleservice = Interface (iinvokable)
[' {a454abf4-3610-70c0-e88f-f2f022f2a747} ']
function Complexadd (const A:tcomplex; Const B:tcomplex): Tcomplex; stdcall;
function Loop (const level:integer): tloopable; stdcall;
function Getclassab:tclassa; stdcall;
End;

function Getisampleservice (Usewsdl:boolean = System.false; addr:string = "; Httprio:thttprio = nil): Isampleservice;


Implementation

function Getisampleservice (Usewsdl:boolean; addr:string; Httprio:thttprio): Isampleservice;
Const
defwsdl = ' Http://localhost/MyServices/SampleService/libss.dll/wsdl/ISampleService ';
Defurl = ' Http://localhost/MyServices/SampleService/libss.dll/soap/ISampleService ';
defsvc = ' Isampleserviceservice ';
defprt = ' Isampleserviceport ';
Var
Rio:thttprio;
Begin
Result: = nil;
if (Addr =

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.