[xml][libcurl] envoyer un HTTP POST avec du XML et LIBCURL
bonjours,
j'essaye depuis 2 jours d'envoyer une simple requete HTTP POST avec la librairie LIBCURL en C++.
le probleme, c'est que j'ai beau suivre les exemples que je trouve sur le site de libcurl le XML n'est jamais ajoute correctement a la requete.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
void Example4()
{
CURL *curl;
CURLcode res;
struct curl_slist *headers=NULL;
headers = curl_slist_append(headers, "Content-Type: text/xml");
char *url = "http://my.server.com";
/* get a curl handle */
curl = curl_easy_init();
if(curl)
{
curl_easy_setopt(curl,CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_POST, 1);
const char* postmess = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n<DescribeCoverage xmlns=\"http://www.opengis.net/wcs/1.1.1\" \nxmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \nservice=\"WCS\" version=\"1.1.1\" xsi:schemaLocation=\"http://www.opengis.net/wcs/1.1.1 http://schemas.opengis.net/wcs/1.1.1/wcsAll.xsd\">\n<Identifier>wcs111_wcs_l7_mspix</Identifier>\n</DescribeCoverage>\n";
printf(postmess);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postmess);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, sizeof(postmess));
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_perform(curl);
curl_slist_free_all(headers);
/* always cleanup */
curl_easy_cleanup(curl);
}
} |
est ce que quelqu'un connait un peu cette librairie ?
merci
XXiemeciel