cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Sending SOAP query using CURLOPT_POST not working for me

From: <nitin.mittal_at_rsa.com>
Date: Tue, 5 Jan 2010 00:17:56 -0500

> On Mon, 4 Jan 2010, Lars Nilsson wrote:

       if ((bodyStruct = (struct MemoryStruct *) malloc(sizeof(struct
MemoryStruct))) == NULL) exit(1);
       curl_easy_setopt(ch, CURLOPT_FILE, bodyStruct);

> Isn't mem in the callback function the allocated value of bodyStruct?
> My guess is simply that while bodyStruct/mem is valid allocated
> memory, mem->memory for instance is not, and realloc would choke on an
> invalid, non-null, memory reference being passed as memory to
> reallocate. Using calloc() or memset() for instance could be a
> solution to the immediate problem.

I replaced this function with

// This is the writer call back function used by curl
 static int writer(char *data, size_t size, size_t nmemb,
                   std::string *buffer)
 {
   // What we will return
   int result = 0;
   
   // Is there anything in the buffer?
   if (buffer != NULL)
   {
     // Append the data to the buffer
     buffer->append(data, size * nmemb);
   
     // How much did we write?
     result = size * nmemb;
   }
   
   return result;
 }

& now there are no crashes.

But, now I get the following ouput:

* About to connect() to 10.31.251.161 port 5985 (#0)
* Trying 10.31.251.161... * connected
* Connected to 10.31.251.161 (10.31.251.161) port 5985 (#0)
* Server auth using Basic with user 'administrator'
> POST /wsman HTTP/1.1
Authorization: Basic YWRtaW5pc3RyYXRvcjpjb2xsZWN0QDIzNA==
Host: 10.31.251.161:5985
Accept: */*
Content-Type: text/xml
SOAPAction: "http://10.31.251.161:5985/wsman"
Content-Length: 1748
Expect: 100-continue

< HTTP/1.1 100 Continue
< HTTP/1.1 415
< Server: Microsoft-HTTPAPI/2.0
< Date: Wed, 06 Jan 2010 05:19:44 GMT
< Connection: close
< Content-Length: 0
<
* Closing connection #0

Still the response, (which I am expecting ) is missing from the server.
I am expecting application, system or security events to be returned
from server.

Please suggest.

Regards,
Nitin

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