Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
9
Erster Beitrag:
vor 5 Jahren, 11 Monaten
Letzter Beitrag:
vor 5 Jahren, 11 Monaten
Beteiligte Autoren:
PETER ZHOU, DerekT, PramaTix, Pragma Tix, Paulo Oliveira, GuenterP

Windev Mobile Android, MYSQL and Webservice

Startbeitrag von PETER ZHOU am 20.07.2012 10:31

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

Antworten:

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.

von DerekT - am 20.07.2012 13:39
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

von Paulo Oliveira - am 20.07.2012 13:50
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

von PETER ZHOU - am 20.07.2012 15:11
Hi DerekT,

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

Thank you again for your help !

Regards,

PETER ZHOU

von PETER ZHOU - am 20.07.2012 15:46
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


von DerekT - am 20.07.2012 15:56
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

von GuenterP - am 20.07.2012 16:23
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...

von Pragma Tix - am 20.07.2012 21:08
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

von PramaTix - am 20.07.2012 21:16
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.