In the previous article you saw how easy it is to create a client and access web services written in other programming languages. While in the previous article you accessed a web service that was already running, in this article we will be creating our own web service from scratch and create a client to access it.
Building a Web Service from Scratch with Delphi - Writing the Methods (Page 2 of 4 )
We need to write our own methods, so I'm going to create two very simple methods to which this service will respond. Go to the interface unit and add the following two methods under the IMyWebServer class definition:
Procedure SetTxt(Const AValue : String); stdcall;
Function GetTxt : String; stdcall;
Then go to the implementation unit and under the TMyWebServer class definition add the following two lines:
Private
TheTxt : String;
And then under these two add the following:
Procedure SetTxt(Const AValue : String); stdcall;
Function GetTxt : String; stdcall;
Then in the implementation section of the unit, add the following code:
function TMyWebServer.GetTxt: String; begin Result := TheTxt; end; procedure TMyWebServer.SetTxt(const AValue: String); begin TheTxt := AValue; end;
So, what does the code do? Well, one of them (settxt) gets parameters from the user and the other reads it and shows the data.