Using Web Services with GBasic (GoDB)
This article shall peep into invoking a webservice from the internet through GoDB. Iam using HTTPDNLD file and XML commands of GoDB.
The application takes the input of a host name and queries a WHOIS server through webservices and gets the detailed information.
For this, I am using
http://www.webservicex.net . You can use other WHOIS server though.
Configuring the proxy:for those having a proxy, you need to configure first before using the application. To go to Configuration screen (inbuilt with GoDB) press Function key 9 (F9). Fillin only the 'ProxyIP' field with your Proxy server. Leave other fields. Click 'save' and 'Go Home'
Querying the web:
the
httpdnld command sends a http request with a host name as the parameter to a webservice. The webservice inturn queries a whois server and sends the result back. The result is saved in a file called test.xml
path$=
http://www.webservicex.net/whois.asmx/GetWhoIS?HostName=+trim$(#txtName$)
RET=HTTPDNLD(path$,"","TEST.XML",1)
if RET=-3 then
msgbox "unable to get file"
endif
Parsing the XML:Now, having created a XML file, we need to parse and display the content in the application for view. Since, the parse is inbuilt in GoDB, my work is much reduced- precisely four lines.
h=XMLParseFile("TEST.XML",1)
if ret>0 then
ret= XMLGoToFirst(h)
while XMLFetch(h,"")=1
str$=str$+ xvalue$(h)
pprint xpath$(h) ; xvalue$(h)
wend
endif
ret=XMLClose(h)
#txtRes$=str$

Overall, if you see, I put up a simple form to enter the host name, a button to query the web and a text area to print the queried results. I stored the data in XML format, parsed it and and displayed in the text area. A variance can be, instead of saving it in XML format, we can also save the same in .txt format and display.

HTTPDOWNLOAD.ZIP