cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Building and Sending SOAP using libcurl

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 12 Sep 2011 10:29:02 +0200 (CEST)

On Sun, 11 Sep 2011, abhishek Kalapatapu wrote:

> Here is my code for sending a SOAP using libcurl

It is completely broken. I suggest you read up the libcurl documentation
first, and then base your initial attempts on an existing example.

You may also want to go back to read up on how you actually write C code. I'll
detail some of the problems below:

> const char *WriteMemoryCallback;

> curl_easy_setopt(ch, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);

CURLOPT_WRITEFUNCTION sets a pointer to a callback function, it should not be
an uninitialized char *.

> curl_slist_free_all(headerlist);

There's no need to free a NULL pointer.

> curl_easy_perform(ch);
>
> //res = curl_easy_perform(curl);

You really should check the return code!

> /* Extract the socket from the curl handle - we'll need it for waiting.
> * Note that this API takes a pointer to a 'long' while we use
> * curl_socket_t for sockets otherwise.
> */
> res = curl_easy_getinfo(ch, CURLINFO_LASTSOCKET, &sockextr);

For waiting? What? That's not at all what you should do. The "sending" and
"receiving" parts of your code are completely wrong. curl_easy_perform()
already did both.

> scurl.c:57:45: warning: incompatible implicit declaration of built-in
> function âmallocâ

Lack of proper header file.

> scurl.c:57:59: error: invalid application of âsizeofâ to incomplete type
> âstruct MemoryStructâ

Lack of proper struct declaration

> scurl.c:57:91: warning: incompatible implicit declaration of built-in
> function âexitâ

Lack of proper header file

> scurl.c:63:72: warning: backslash and newline separated by space

Weirdly formatted string.

> scurl.c:64:22: error: expected â)â before âhttpâ

Bad syntax.

> scurl.c:69:60: error: invalid suffix "G" on integer constant

Wrong syntax.

-- 
  / daniel.haxx.se

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-09-12