cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: How to send SOAP+XML, using the "xml in memory"

From: Patrick Monnerat <Patrick.Monnerat_at_datasphere.ch>
Date: Tue, 1 Jul 2014 15:53:48 +0200

 
Ajay Garg wrote:

>
http://stackoverflow.com/questions/4150710/soap-request-and-response-rea
d-from-and-to-file-using-libcurl-c gives us the solution to sending a
XML, when it ought to be read from a file.

> Is it possible to achieve the same "end result", but wherein the XML
is created "on the fly" during program-run, and not read from a file?

If all data are ready in memory before request, instead of the
CURLOPT_READFUNCTION/CURLOPT_READDATA options you may use
http://curl.haxx.se/libcurl/c/CURLOPT_POSTFIELDS.html or
http://curl.haxx.se/libcurl/c/CURLOPT_COPYPOSTFIELDS.html and specify
the length with
http://curl.haxx.se/libcurl/c/CURLOPT_POSTFIELDSIZE.html.

If the data generation is done during the transfer, you have to update
the read_data() in the example you mention to return a new bunch of
data. You set the callback address as in the example, and you can use
the user data pointer (CURLOPT_READDATA) to pass a data generation
control block of your own (i.e.: it does not have to be a FILE *: its
real type depends on what you are doing with in the read_data function).

I suggest you read http://curl.haxx.se/libcurl/c/curl_easy_setopt.html
thoroughly...

Patrick

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-07-01