Hi,
I can't seem to get curl working.
I want to call a web service via CURL.
I have created the correct XML with soapUI and brought that into
the .prg file.
When i check with wireshark, I can see that the webservice is posted
but it does not seem to take the HTTP headers into account when
posting the message onto the webservice.
I get from the webservice back : "The server cannot service the
request because the media type is unsupported"
This is the example code I am trying to work :
#include "
hbcurl.ch"
#include "
common.ch"
#include "
fileio.ch"
FUNCTION Main( )
LOCAL exitStatus
LOCAL endpointUrl
LOCAL postData
LOCAL curlHandle
LOCAL curlErr
LOCAL cHeader
/* Exit status to return */
exitStatus := 0
endpointUrl = "
http://wsf.cdyne.com/WeatherWS/Weather.asmx"
// Parameters for call
postData := '<soapenv:Envelope xmlns:soapenv="http://
schemas.xmlsoap.org/soap/envelope/" xmlns:weat="
http://ws.cdyne.com/
WeatherWS/">'
postData += '<soapenv:Header/>'
postData += '<soapenv:Body>'
postData += '<weat:GetWeatherInformation/>'
postData += '</soapenv:Body>'
postData += '</soapenv:Envelope>'
? postData
cHeader := "Accept-Encoding: gzip,deflate" + CHR(13) + CHR(10)
cHeader +="Content-Type: text/xml;charset=UTF-8" + CHR(13) + CHR(10)
cHeader +='SOAPAction: "
http://ws.cdyne.com/WeatherWS/
GetWeatherInformation"' + CHR(13) + CHR(10)
cHeader +="User-Agent: Jakarta Commons-HttpClient/3.1" + CHR(13) +
CHR(10)
? cHeader
/* Initialise libcurl */
curl_global_init()
/* Get a curl handle */
curlHandle := curl_easy_init()
IF .NOT. EMPTY(curlHandle)
curl_easy_setopt(curlHandle,HB_CURLOPT_HTTPHEADER, cHeader)
/* Set the endpoint to send the POST to */
curl_easy_setopt(curlHandle, HB_CURLOPT_URL, endpointUrl);
/* Specify the POST data */
curl_easy_setopt(curlHandle, HB_CURLOPT_POSTFIELDS, postData);
/* Execute the POST, response goes to STDOUT */
curlErr = curl_easy_perform(curlHandle);
/* Report any errors */
IF .NOT. EMPTY(curlErr)
? curl_easy_strerror(curlErr)
ENDIF
ELSE
? "No handle"
ENDIF
IF .NOT. EMPTY(curlHandle)
/* Clean-up libcurl */
curl_global_cleanup()
ELSE
exitStatus = 1
ENDIF
/* Return the exit status */
RETURN exitStatus