First, the service side
Add function in Ro (add Antoine Connection,adoquery,dataprovider on Impl)
function Tnewservice.getdata (const sqlstr:utf8string): Variant;
Begin
Qry1. Close;qry1. Sql. Text:= ";
Qry1. Sql. TEXT:=SQLSTR;
Qry1. Open;
DS1. Data:=dtstprvdr1. Data;
Result:=ds1. xmldata;//Pass a XMLData to the client
End
Second, the client calls the same, add Wsdl,xe5 Android platform call WebService
Client Add Httprio,stringgrid etc (FMX data shows no DataGrid in the moment)
Reading data Code
HTTPRIO1. url:= ' Http://192.168.1.103:8099/SOAP ';
clientdataset1.xmldata:= (HTTPRIO1 as soap. NewService). GetData (' SELECT top [Employeeid],[employeename],[departmentid] from [gm_mt].[ DBO]. [Gm_kq_employee] ');
While not clientdataset1.eof do
Begin
Stringgrid1.cells[0,i]:=clientdataset1.fieldbyname (' EmployeeID '). aswidestring;
Stringgrid1.cells[1,i]:=clientdataset1.fieldbyname (' EmployeeName '). asstring;
Stringgrid1.cells[2,i]:=clientdataset1.fieldbyname (' DepartmentID '). asstring;
LISTBOX1.ITEMS.ADD (Clientdataset1.fieldbyname (' EmployeeName '). aswidestring);
i:=i+1;
Clientdataset1.next;
End
Now encountered the problem is the client display Chinese garbled! Temporarily unresolved, client uses ANSITOUTF8 not resolved
10-10 Chinese garbled has been resolved: The Text field in the database must be set to nvarchar
XE5 Android via WebService access operation MSSQL Database