cURL / Mailing Lists / curl-library / Single Mail

curl-library

Fw: Problem using libcurl

From: Francis Dagenais <francis_at_voxtel.com>
Date: Mon, 15 Jul 2002 11:50:29 -0400

I tried what you just said, and it changed the behavior of my application. The chained list "headerlist" is not looping anymore (good!). And the second post now seems to start (I can see in the curl traces) but doesn't end correctly (still core dumped). I'm continuing the search (if you have an idea, please post!)

thank you,
Francis Dagenais
  ----- Original Message -----
  From: Mike Tardif
  To: 'Francis Dagenais'
  Sent: Monday, July 15, 2002 11:32 AM
  Subject: RE: Problem using libcurl

  Francis

  You need to reinitialize your headerlist to NULL before each post.

  See below.

  Cheers,

  Mike Tardif
  Abobe Systems Canada.

  -----Original Message-----
  From: Francis Dagenais [mailto:francis_at_voxtel.com]
  Sent: Monday, July 15, 2002 11:27 AM
  To: curl-library_at_lists.sourceforge.net
  Subject: Problem using libcurl

  Hi,
    I'm using libcurl to send SOAP-XML messages over HTTPS. I'm now able to do 1 post, and receive the answer without problem. But when I try to do 2 post in a row, the second post doesn't end correctly, and my C program ends in a core dump. Here is what I've programmed:

CURL *ch;struct curl_slist *headerlist=NULL;struct MemoryStruct *bodyStruct=NULL;char _gatineauSoapReq[2000]="";
void _gatineauInit() { ch = curl_easy_init(); curl_easy_setopt(ch, CURLOPT_URL, transactionServerUrl3); curl_easy_setopt(ch, CURLOPT_POST, 1); curl_easy_setopt(ch, CURLOPT_HEADER, 1); curl_easy_setopt(ch, CURLOPT_VERBOSE, 1); curl_easy_setopt(ch, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); if ((bodyStruct = (struct MemoryStruct *) malloc(sizeof(struct MemoryStruct))) == NULL) exit(1); curl_easy_setopt(ch, CURLOPT_FILE, bodyStruct);}
void _gatineauEndReq() { free(bodyStruct); curl_slist_free_all(headerlist); curl_easy_cleanup(ch);}
int _gatineauExtractRetour(char *response) { char *tok="", buf[64]="", *p=""; p = strstr(response, "<Retour>"); tok = strtok(p, ">"); tok = strtok(NULL, "<"); strcpy(buf, tok); return(atoi(buf));}
void _gatineauValidateNow( const char *arg1, const char *arg2, const char *arg3, const char *arg4) {
  // I make sure that headerlist is erased before rebuilding it with the soap function curl_slist_free_all(headerlist);
headerlist = NULL;
  headerlist = curl_slist_append(headerlist, "Content-Type: text/xml"); headerlist = curl_slist_append(headerlist, "SOAPAction: \"http://blabla.com/blabla_services/ValidateNow\""); sprintf(_gatineauSoapReq, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\<soap:Body>\<ValidateNow xmlns=\"namespace://xml.blabla.com/shemas/blabla_service/blabliblo/\">\<IdSessionTel>%s</IdSessionTel>\<NoMember>%s</NoMember>\<NoActivity>%s</NoActivity>\<ready>%s</ready>\</ValidateNow>\</soap:Body>\</soap:Envelope>", arg1, arg2, arg3, arg4); curl_easy_setopt(ch, CURLOPT_POSTFIELDS, _gatineauSoapReq); curl_easy_setopt(ch, CURLOPT_HTTPHEADER, headerlist); curl_easy_perform(ch);}
 
void _gatineau() { char *strToSend="", buf[2000]="", buf2[256]="", *dtmf="", *msgDir="", msgPath[128]="", *periodInfo=""; int i=0, retour=0; _gatineauInit(); _gatineauValidateNow("1234", "0052", "654321", "0"); printf("Retour: %s\n", bodyStruct->memory); retour = _gatineauExtractRetour(bodyStruct->memory); printf("Retour1: --%d--\n", retour);
  _gatineauValidateNow("1235", "0053", "123456", "1"); printf("Retour: %s\n", bodyStruct->memory); retour = _gatineauExtractRetour(bodyStruct->memory); printf("Retour2: --%d--\n", retour); _gatineauEndReq();}
I think that may be the problem is within the headerlist function :
  curl_slist_free_all(headerlist);
  headerlist = curl_slist_append(headerlist, "Content-Type: text/xml");
If someone has already done something with soap-xml or has made several posts within the same curl session, please help!

  Thank you,
  Francis Dagenais

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2002-07-15