Home > Back-end >  Web service calls to the server error, solving.
Web service calls to the server error, solving.

Time:09-22



The server-side code: unit ws_chkhjIntf;

Interface

USES InvokeRegistry, Types, XSBuiltIns unyrecord;

Type

{Invokable interfaces must derive from IInvokable}
Iws_chkhj=interface (IInvokable)
[' {00 eb914c - CAC8-41 e5 - A38E - 7 a6ad7165aac} ']

{the Methods of Invokable interface must not use the default}
{calling convention. Stdcall is it}

//function getchkny () : TStringDynArray; Stdcall;
//function getny () : TStringDynArray; Stdcall;
The function getny () : tnyrecords; Stdcall;
end;

Implementation

Initialization
{Invokable interfaces must be registered}
InvRegistry. RegisterInterface (TypeInfo (Iws_chkhj));

End.

The unit ws_chkhjImpl;

Interface

USES InvokeRegistry, Types, XSBuiltIns ws_chkhjIntf, Unit6, smod, unyrecord;

Type

{Tws_chkhj}
Tws_chkhj=class (TInvokableClass Iws_chkhj)
Public
//function getchkny () : TStringDynArray; Stdcall;
//function getny () : TStringDynArray; Stdcall;
The function getny () : tnyrecords; Stdcall;
end;

Implementation
//function Tws_chkhj. Getny: TStringDynArray; Stdcall;
The function Tws_chkhj. Getny () : tnyrecords; Stdcall;
Var icount, ino: Integer;
Ws_smod: Tws_smod;
The begin
Ino:=1;
Ws_smod:=Tws_smod. Create (nil);
//ws_smod. ADODataSet1. Active:=True;
//ws_smod ADODataSet1. ClearFields;
Ws_smod.ADODataSet1.Com mandText:='select distinct ny from chk_ha1 order by ny desc';
Ws_smod. ADODataSet1. Prepared;
Ws_smod. ADODataSet1. Open;
Icount:=ws_smod ADODataSet1. RecordCount;
SetLength (Result, icount);
While not ws_smod. ADODataSet1. Eof do
The begin
Inc (ino);
Result [ino]. Ny:=ws_smod ADODataSet1. FieldByName (' ny '). The Value;
//the Result (ino) :=ws_smod ADODataSet1. FieldByName (' ny '). The Value;
Ws_smod. ADODataSet1. Next;
end;
Ws_smod. ADODataSet1. Active:=False;

end;
Initialization
{Invokable classes must be registered}
InvRegistry. RegisterInvokableClass (Tws_chkhj);
End.


The unit unyrecord;
Interface
USES the
InvokeRegistry XSBuiltIns;
Type
Tnyrecord=class (TRemotable)
Private
Fny: string;
Published
The property ny: string read fny write fny;
end;
Tnyrecords=array of Tnyrecord;

Implementation

Initialization
Remclassregistry. RegisterXSClass (tnyrecord, 'http://www.w3.org/2001/xmlschema', 'tnyrecord', ' ', false);
Remtyperegistry. RegisterXSInfo (TypeInfo (tnyrecords), 'http://www.w3.org/2001/xmlschema', 'tnyrecords');
Finalization
Remclassregistry. UnRegisterXSClass (tnyrecord);
Remtyperegistry. UnRegisterXSInfo (TypeInfo (tnyrecords));
End.

Nit Unit6.
Interface
USES the
SysUtils, Classes, HTTPApp InvokeRegistry WSDLIntf, TypInfo, WebServExp,
WSDLBind XMLSchema, WSDLPub SOAPPasInv, SOAPHTTPPasInv, SOAPHTTPDisp,
WebBrokerSOAP DBClient, Provider, DB, ADODB library;
Type
TWebModule6=class (TWebModule)
HTTPSoapDispatcher1: THTTPSoapDispatcher;
HTTPSoapPascalInvoker1: THTTPSoapPascalInvoker;
WSDLHTMLPublish1: TWSDLHTMLPublish;
Procedure WebModule6DefaultHandlerAction (Sender: TObject;
Request: TWebRequest; Response: TWebResponse; Var Handled: Boolean);
Private
{Private declarations}
Public
{Public declarations}
end;

Var
WebModule6: TWebModule6;

Implementation

{$R *. DFM}

Procedure TWebModule6. WebModule6DefaultHandlerAction (Sender: TObject;
Request: TWebRequest; Response: TWebResponse; Var Handled: Boolean);
The begin
WSDLHTMLPublish1. ServiceInfo (Sender, Request, Response, Handled);
end;
End.


The Unit smod;
Interface
USES SysUtils, Classes, InvokeRegistry, Midas, SOAPMidas, SOAPDm, Provider, DB,
DBTables ADODB, DBClient;
Type
Iws_smod=interface (IAppServerSOAP)
[' {b58 b9b BA26B1ED - 1-4 - a6380adc64a B8A4-1} ']
end;
Tws_smod=class (TSoapDataModule Iws_smod, IAppServerSOAP, IAppServer)
ADOConnection1: TADOConnection;
ADODataSet1: TADODataSet;
DataSetProvider1: TDataSetProvider;
Ds2: the TClientDataSet;
Private
Public
end;
Implementation

{$R *. DFM}

Procedure Tws_smodCreateInstance (out obj: TObject);
The begin
Obj:=Tws_smod. Create (nil);
end;

Initialization
InvRegistry. RegisterInvokableClass (Tws_smod Tws_smodCreateInstance);
InvRegistry. RegisterInterface (TypeInfo (Iws_smod));
End.

The client code:
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
//The types declared in this file were generated from The data read from The
//WSDL File described below:
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull