Welcome! Log In Create A New Profile

Advanced

Windev Mobile Android, MYSQL and Webservice

Posted by PETER ZHOU 
PETER ZHOU
Windev Mobile Android, MYSQL and Webservice
July 20, 2012 12:31PM
Hi,

I understand that there's a need to create webservice to support connection to MYSQL when using WM Android ( for external database).

I don't know anything about webservice.

Can anyone help by give simple example ( for example to connect to a MYSQL table - select * ) including example for the webservice ?

Regards,

PETER ZHOU
Peter

A webservice is required to connect to any external DB from a WM Android app.

What you need to do..........

Create a webservice - basically this is a WinDev app without windows.
Use normal WD functions to connect to the DB
Create a method (Global Procedure) that extracts the required data from the DB - convert the result into XML and return this as the result of the method.

The webservice needs to be published onto a server running WebDev Application server - needs to be the same version of greater that the WD version used to create the webservice - (the free 10 user version works OK for testing)

From WM - import the webservice, this will display all the public methods available.
Execute the method sending parameters as required.
Receive the result (XML as above) and parse(read) this directly into a looper or write to a local SQLite data table as required.
Paulo Oliveira
Re: Windev Mobile Android, MYSQL and Webservice
July 20, 2012 03:50PM
If you need more than 10 simultaneous connections and don't want to pay for the WAS you can develop one socket server app with windev and connect to it from the mobile.
Under the windev in the components you can find one sample of the server and client socket apps.

The data treatment can be the same with webservices or sockets, passing it as XML or any other format you may decide in the sockets apps.

windev xx\Components\Sample components\WD Socket



Edited 1 time(s). Last edit at 07/20/2012 03:58PM by Paulo Oliveira.
PETER ZHOU
Re: Windev Mobile Android, MYSQL and Webservice
July 20, 2012 05:11PM
Hi DerekT,

I'm going thru the web service examples under WINDEV 16 & noticed it (server version) generate the '.wsdl' & '.awws' files where the .awws is deployed under the webdev app server.

In the (client version) of the web service example, it's using the '.wdsdl' file.

How do i generate the (server version) to give the client the '.wdsdl' file ?

Sorry for the trouble..

Regards,

PETER ZHOU
PETER ZHOU
Re: Windev Mobile Android, MYSQL and Webservice
July 20, 2012 05:46PM
Hi DerekT,

Please Ignore my previous question on the '.wdsdl', I have found the answer.

Thank you again for your help !

Regards,

PETER ZHOU
Quote
PETER ZHOU
Hi DerekT,

I'm going thru the web service examples under WINDEV 16 & noticed it (server version) generate the '.wsdl' & '.awws' files where the .awws is deployed under the webdev app server.
The wsdl is what is created when you generate the webservice - the generation wizard will ask you for the address of the server on which to publish.
The awws is created at the same time - cannot remember the address syntax but when you have successfully generated a list will be displayed and towards the bottom the links to the wsdl and awws are displayed


In the (client version) of the web service example, it's using the '.wdsdl' file.
Correct - you need to import the webservice from the server (Workshop/Webservices)

How do i generate the (server version) to give the client the '.wdsdl' file ?
As item 2

Sorry for the trouble..
Not a problem - we have all been here


Regards,

PETER ZHOU
GuenterP
Re: Windev Mobile Android, MYSQL and Webservice
July 20, 2012 06:23PM
Quote
Paulo Oliveira
If you need more than 10 simultaneous connections and don't want to pay for the WAS you can develop one socket server app with windev and connect to it from the mobile.
Under the windev in the components you can find one sample of the server and client socket apps.

The data treatment can be the same with webservices or sockets, passing it as XML or any other format you may decide in the sockets apps.

windev xx\Components\Sample components\WD Socket

Hi, just as a small annotation: a socket connection connects to a certain port on the 'server' and therefore is single-connect at a time. You have to take care in your WM-app how it will behave whenever the server is busy with dealing with another request. If request-handling is fast, no problem. Just a smal wait-loop. Forcing the server into big and long lasting queries is not that good for others trying to connect. In this respect, the web service is much better, it is multi-threaded and extending the WB App Server's number of connections is may be the better solution.

Btw, I believe that it is quite a bit frustrating not to have a direct data connection to the server from an Android device like with any connected Windows PCs. Has anyone tested the performance of a WinDev/Java application started by a small Android apk? What else speaks against WD-Java?

Kind regards, Guenter
Pragma Tix
Re: Windev Mobile Android, MYSQL and Webservice
July 20, 2012 11:08PM
Quote
DerekT

Create a method (Global Procedure) that extracts the required data from the DB - convert the result into XML and return this as the result of the method.

Comverting to XML is not necessary .
Snip
WSDL client code

LOCAL
	resp is Array_SelectCompaniesByCountryResponse
	
	_id, _company, _country is string 
	pict is Buffer
	
	d is Date
	
TableDeleteAll(Table1)

resp = Array_SelectCompaniesByCountry( ED_COUNTRY )

FOR i = 1 _TO_ resp.Array_SelectCompaniesByCountryResult..Occurrence
	
	_company = resp.Array_SelectCompaniesByCountryResult.CorporateName
	_id = resp.Array_SelectCompaniesByCountryResult.CompanyID
	_country = resp.Array_SelectCompaniesByCountryResult.country
	pict = resp.Array_SelectCompaniesByCountryResult.Logo
	//d = resp.Array_SelectCompaniesByCountryResult.CreatedAt
	
	TableAddLine(Table1, _id, _company, _country, pict)
	
	
END

WebService code
PROCEDURE Array_SelectCompaniesByCountry(country is string)
	Companies is dynamic array of 0 stCompany

	IF HExecuteQuery(QRY_Company_by_Country,hQueryDefault, country) THEN
	
		FileToArray(Companies,QRY_Company_by_Country)	

	END

	HFreeQuery(QRY_Company_by_Country)

RESULT Companies

Finally the company structure which is UML generated
tCompany est une structure
		CompanyID est un 8-byte int //Corporate Name
		CorporateName est un string //address
		address est un string //Additional address
		AddressNext est un string //Zip code
		ZipCode est un string //City
		City est un string //country
		country est un string //Web
		Web est un string //Email
		Email est un string //Phone
		Phone est un string //Mobil
		Mobil est un string //Fax
		Fax est un string //Logo of the company
		Logo est un Buffer                                       // Picture base64 encoded
		CreatedAt est un Date
FIN
HTH BLS
PS : Unfortunately WX17 generated Webservices have a serious bug, I am creating a test case for PCSOFT...
PramaTix
Re: Windev Mobile Android, MYSQL and Webservice
July 20, 2012 11:16PM
Mysnip problem .. Kills [ i ]
Client code has to be as follows ..
_company = resp.Array_SelectCompaniesByCountryResult [ i ] . CorporateName
etc..
Have tested the Client code in WD17. Speed is ok. No tests on Smart devices,though.
BLS
Re: Windev Mobile Android, MYSQL and Webservice
November 09, 2022 02:31AM
Dear Derek.

I am going trough the same scenario that you discussed in this topic. Also very inexperienced with mobile applications. Is all these steps still valid for newer versions of Windev?. I am currently using WD25

Please advice and thank you very much in advance
Re: Windev Mobile Android, MYSQL and Webservice
November 18, 2022 12:13PM
Hello,

When is comes to access in MySQL/MariaDB from Mobile app, I prefer to use Php4WD.

It is very easy to setup and configure.

If you are interested in use it you can download it from below link.

[mega.nz]

--
Yogi Yang
Re: Windev Mobile Android, MYSQL and Webservice
November 18, 2022 01:27PM
Greeting
I used this php4wx script in older versions of WM and it worked perfectly.
My new mobile app (WM 24) won't work properly with the new php4wx script.
I have already asked a question on this forum, no one could give me an answer as to why the error that I am sending here in the attachment appears.

[infosonline.net]
Attachments:
open | download - php4wx.jpg (92.6 KB)
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: