Re: Euphoria SOAP client

new topic     » goto parent     » topic index » view thread      » older message » newer message

Keep in mind that POST and GET are two different ways of doing the same thing. I mention this because it makes it easier to understand the way in which you interface with a CGI server, which the SOAP server is.

To take an example, go to this page of mine:

http://www.wazu.jp/hosting/pricing.exu

Fill in a few forms, tick a few boxes, and hit 'Price This Plan'.

You have just sent data to my server using POST.

Now enter:

http://www.wazu.jp/hosting/pricing.exu?&email_count=7&disk_count=100&transfer_count=33&sql_count=3&multi_count=1&billing_currency=JPY&price_me=Price+or+Re-Price+This+Plan&domain_name=+&given_name=+&family_name=+&country=+&email=+&email_check=+

in the address bar.

You have just sent data to my server using a GET.

Note what's in the url and what's displayed on the page.

When large amounts of data are involved, POST is more appropriate. But you can see that essentially the same data are sent in each case.

For SOAP, you have to generate your XML, and send it to the CGI interface, using POST.

I use a Euphoria implementation of libcurl, and have one program that does webscraping, using POST, daily.

Here is an extract of the code, to show you how easy it is. The program is a few thousand lines long, but I've just extracted the relevant libcurl statements.

include C:\EUPHORIA\INCLUDE\euLibCurl.ew 
 
atom curl_handle 
atom errp -- curl error 
errp = allocate(CURL_ERROR_SIZE) 
 
 
--**************************************************************** 
--**********           function get_url           **************** 
--**************************************************************** 
function get_url(sequence url, object form_data) 
-- form_data can be NO_FORMS 
-- returns HTML page or error code 
object buffer, buffer2 
if connexion_mode = SOCKS then 
	void = curl_easy_setopt(curl_handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5) 
	void = curl_easy_setopt(curl_handle, CURLOPT_PROXY, "127.0.0.1:4567") 
	void = curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE, "C:\\EUPHORIA\\accounts\\SOCKS_cookies") 
	void = curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, "C:\\EUPHORIA\\accounts\\SOCKS_cookies") 
	void = curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)") 
elsif connexion_mode = Proxy then 
	void = curl_easy_setopt(curl_handle, CURLOPT_PROXYTYPE, CURLPROXY_HTTP) 
	void = curl_easy_setopt(curl_handle, CURLOPT_PROXY, "192.168.0.1:4480") 
	void = curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE, "C:\\EUPHORIA\\accounts\\Proxy_cookies") 
	void = curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, "C:\\EUPHORIA\\accounts\\Proxy_cookies") 
	void = curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4") 
else -- Direct 
	void = curl_easy_setopt(curl_handle, CURLOPT_PROXYTYPE, CURLPROXY_HTTP) 
	void = curl_easy_setopt(curl_handle, CURLOPT_PROXY, "") 
	void = curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE, "C:\\EUPHORIA\\accounts\\Direct_cookies") 
	void = curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, "C:\\EUPHORIA\\accounts\\Direct_cookies") 
	void = curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "Opera/9.21 (Windows NT 5.1; U; en)") 
end if 
 
void = curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0) 
-- CURLOPT_CAINFO and CURLOPT_CAPATH would be used to point to certificates, 
-- but the line above says not to verify the SSL certificate 
 
if sequence (form_data) then 
	void = curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, form_data) 
else 
	void = curl_easy_setopt(curl_handle, CURLOPT_HTTPGET, 1) 
end if 
 
void = curl_easy_setopt(curl_handle, CURLOPT_URL, url) 
if sequence(form_data) then 
	showMessage(sprintf("Downloading file %s : %s",{url,form_data})) 
else 
	showMessage(sprintf("Downloading file %s",{url})) 
end if 
buffer = curl_easy_perform_ex(curl_handle) 
if atom(buffer) then 
	showMessage(sprintf("Error '%s' downloading file", {peek_sequence(errp, CURL_ERROR_SIZE) } ) ) 
end if 
return buffer 
end function 
-------------------------------------------------------------------------------- 
 
curl_easy_cleanup(curl_handle) 
curl_global_cleanup() 
free(errp) 
 
if  curl_global_init(CURL_GLOBAL_ALL) != 0 then 
	warnErr("Could not initialise libCurl\n\nContinue?") 
end if 
 
curl_handle = curl_easy_init() 
void = curl_easy_setopt(curl_handle, CURLOPT_ERRORBUFFER, errp) 
void = curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1) 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu