Hi Pritpal,
here a SOAP example. I can communicate with a mono webservice either locally
(localhost) or over the network:
------------------------------
#include "
hbcurl.ch"
#include "
common.ch"
#include "
fileio.ch"
function fHttpExecute(cxml)
local endpointUrl,curlHandle,curlErr
local aHeader,chpmserv,cc1
cc1 := ""
cservice := "InformationsService"
caction := "LiefereKernversion"
chpmserv := "localhost"
endpointUrl = "http://"+chpmserv+":22220/"+cservice+".asmx"
aHeader := {}
AADD(aHeader,"Accept-Encoding: gzip,deflate" )
AADD(aHeader,"Content-Type: application/soap+xml;charset=UTF-8")
AADD(aHeader,'action="
http://some-website.de/'+caction+'"')
curlHandle := curl_easy_init()
if !empty(curlHandle)
/* Specify the Header data */
curl_easy_setopt(curlHandle,HB_CURLOPT_HTTPHEADER,aHeader)
/* Set the endpoint to send the POST to */
curl_easy_setopt(curlHandle, HB_CURLOPT_URL, endpointUrl)
/* Setup response data */
curl_easy_setopt( curlHandle, HB_CURLOPT_DOWNLOAD )
curl_easy_setopt( curlHandle, HB_CURLOPT_DL_BUFF_SETUP )
/* Specify the POST data */
curl_easy_setopt(curlHandle, HB_CURLOPT_POST, 1)
curl_easy_setopt(curlHandle, HB_CURLOPT_POSTFIELDS, cxml)
/* Do everything */
curlErr := curl_easy_perform(curlHandle)
/* Report any errors */
if empty(curlErr)
/* store response in variable */
cc1 := curl_easy_dl_buff_get( curlHandle )
else
? curl_easy_strerror(curlErr)
endif
else
? "No handle"
endif
if !empty(curlHandle)
/* Clean-up libcurl */
curl_global_cleanup( curlHandle )
else
? "Error"
endif
if empty(cc1)
? "Error"
endif
return cc1
-------------------------
You need to know the exact endpointUrl, the service and action. This information
is contained in the WSDL files. Sometimes it can be hard to get the header lines
in aHeader right so that the webservice accepts the message.
CU
Claudia