Android Question How to process the dataset returned by a webservice

Theo_van_Putten

New Member
Licensed User
Longtime User
Many important functions and dataobjects come to us in the form of Webservices. And for those who are not familiair with webservices, a short explanation.

Webservices are probably best seen as a modern form of the old remote procedure call (RPC). A piece of software residing on another (remote) computer and executed there.
Webservices have methods (procedures or functions) like calulate, convert, pay, book, cancel, etc, etc.
And these methods can be called with or without passing parameters to the webservice method(s).
One of the beautifull things about a webservice is that it is completely hidden how the webservice comes to its results, which hardware is involved etc. Furthermore there are many other subjects related with webservices. Like authorisation etc. I will not discuss them here.

Webservices can return any form of data(structure ). It could be a boolean as "true" or a string as "done" are an integer or even a dataset.

The call and use of a webservice is relatively easy. You have to know the location (IP address ) of where the webservice resides and you have to know the relevant methods. And then it is easy. In most of the cases.
A good example of all of this is the example on the currency converter. It needs a currency_from (like USD) and a currency_to (Like EUR) and an amount. And when you execute the relevant method, passing it the three parameters, it returns a converted amount.

Some webservices do not return a simpel one dimensional value. They return a dataset (or a list). The problem that I have is that I do not know (in Basic4Android) how to get this dataset and how to list its contents.

I have written a very simpel webservice (in VB.Net). The sample code is listed.

<WebMethod()> _
Public Function Test () As DataSet
Dim MyConnection As SqlConnection
MyConnection = New SqlConnection
Dim sConnect As String = "Data Source=SERVER\SQLSERVER;Initial Catalog =CADCAM;Integrated Security=True"
Dim sSQL As String = "Select * from Wapening"
Try
MyConnection.ConnectionString = sConnect
MyConnection.Open()
Catch ex As Odbc.OdbcException
Throw ex
End Try
Dim MyAdapter As SqlDataAdapter = New SqlDataAdapter(sSQL, MyConnection)
Dim Mydataset As DataSet = New DataSet
MyAdapter.Fill(Mydataset)
Return Mydataset
End Function

As can be seen, a relatively simple webservice. It returns a dataset with all the rows (and all the colums) of a table.

Writing the clientside and consume the results (the dataset) is very very straightforward.

Try
Dim MyService As WebReference2.Service1 = New WebReference2.Service1
Dim MyDataset As DataSet = New DataSet
MyDataset = MyService.Test
DataGridView1.DataSource = MyDataset.Tables(0)
DataGridView1.Refresh()
Catch ex As Exception
MsgBox(ex.ToString)
End Try

And the listview shows all rows and all columns.

But how to write such a client in Basic4Android?.

I think I have the code to call the webservice. But I can not get hold of the returned dataset.

Any help would be much appreciated.
 

eps

Expert
Licensed User
Longtime User
try searching for remote odbc, there are a number of examples.

I would post a link, but my phone won't allow me to for some reason..
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Many important functions and dataobjects come to us in the form of Webservices. And for those who are not familiair with webservices, a short explanation.

Webservices are probably best seen as a modern form of the old remote procedure call (RPC). A piece of software residing on another (remote) computer and executed there.
Webservices have methods (procedures or functions) like calulate, convert, pay, book, cancel, etc, etc.
And these methods can be called with or without passing parameters to the webservice method(s).
One of the beautifull things about a webservice is that it is completely hidden how the webservice comes to its results, which hardware is involved etc. Furthermore there are many other subjects related with webservices. Like authorisation etc. I will not discuss them here.

Webservices can return any form of data(structure ). It could be a boolean as "true" or a string as "done" are an integer or even a dataset.

The call and use of a webservice is relatively easy. You have to know the location (IP address ) of where the webservice resides and you have to know the relevant methods. And then it is easy. In most of the cases.
A good example of all of this is the example on the currency converter. It needs a currency_from (like USD) and a currency_to (Like EUR) and an amount. And when you execute the relevant method, passing it the three parameters, it returns a converted amount.

Some webservices do not return a simpel one dimensional value. They return a dataset (or a list). The problem that I have is that I do not know (in Basic4Android) how to get this dataset and how to list its contents.

I have written a very simpel webservice (in VB.Net). The sample code is listed.

<WebMethod()> _
Public Function Test () As DataSet
Dim MyConnection As SqlConnection
MyConnection = New SqlConnection
Dim sConnect As String = "Data Source=SERVER\SQLSERVER;Initial Catalog =CADCAM;Integrated Security=True"
Dim sSQL As String = "Select * from Wapening"
Try
MyConnection.ConnectionString = sConnect
MyConnection.Open()
Catch ex As Odbc.OdbcException
Throw ex
End Try
Dim MyAdapter As SqlDataAdapter = New SqlDataAdapter(sSQL, MyConnection)
Dim Mydataset As DataSet = New DataSet
MyAdapter.Fill(Mydataset)
Return Mydataset
End Function

As can be seen, a relatively simple webservice. It returns a dataset with all the rows (and all the colums) of a table.

Writing the clientside and consume the results (the dataset) is very very straightforward.

Try
Dim MyService As WebReference2.Service1 = New WebReference2.Service1
Dim MyDataset As DataSet = New DataSet
MyDataset = MyService.Test
DataGridView1.DataSource = MyDataset.Tables(0)
DataGridView1.Refresh()
Catch ex As Exception
MsgBox(ex.ToString)
End Try

And the listview shows all rows and all columns.

But how to write such a client in Basic4Android?.

I think I have the code to call the webservice. But I can not get hold of the returned dataset.

Any help would be much appreciated.




you might have a class / library that deals with:

XML Schema
UDDI (Universal Description, Discovery and Integration)
WSDL (Web Services Description Language)
SOAP (Simple Object Access Protocol)

try searching on Google:

site:basic4ppc.com "web service" OR "webservice" OR WSDL class OR library
 
Upvote 0
Top