Greetings!
I got a silly question, for I'd like to get some aid. I'm practicing the call of Web Services from Delphi7. I'm testing it with a WS made in C# 2010. That is what I got so far:
This is the Web Service in C#:
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public int countChars(string text)
{
int n = 0;
if (text != null)
return text.Length;
else
return n;
}
}
This is the Web Client in Delphi (just a form with a button and a SOAP object):
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, InvokeRegistry, Rio, SOAPHTTPClient, StdCtrls, Service1;
type
TForm1 = class(TForm)
Button1: TButton;
Serv: THTTPRIO;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
procedure TForm1.Button1Click(Sender: TObject);
var
size : Integer;
begin
try
size := (Serv as Service1Soap).countChars('Hello');
ShowMessage(IntToStr(size));
except
on e:Exception do
begin
ShowMessage(e.Message);
end
end
end;
end.
The thing is, when I do call the web service, text is received as a null entry, instead of the word "Hello".
What I have tried:
I tried changing to PChar in Delphi. Looking for info on internet. Even read about BTSr but no idea how to use that (I supose that's for COM stuff). I wonder why I keep getting a null string. What am I missing?
Edited: Seems like I'm getting a similar issue with Integers. Tried to do an addittion between 2 numbers (4 and 5) and I get 0 as result.
C# Web Method:
[WebMethod]
public int sumAB(int a, int b)
{ return a + b; }
Delphi call to Method:
procedure TForm1.Button1Click(Sender: TObject);
var
sum, a, b : Integer;
begin
a := 5;
b := 4;
sum:= (Serv as Service1Soap).sumAB(a,b);
ShowMessage(IntToStr(sum));
end;