Thanks for your reply Daniel...

Daniel, do you have an example code illustrating the use of CURL_POST?

I am trying to collect some event logs from a remote computer & for that
I need to POST a SOAP query to the remote computer. I am able to do this
with WinHttp calls but trying my hands to achieve the same results using
libcurl to make my application platform independent.

So my requirement is:
I should send a POST query to some remote windows server, say Windows
2008 & should get back response from the server, sending me, say the
application event logs.

Can you please direct me to some link or provide me some sample code
giving me an idea of going about this problem?

I am trying something like this, but it doesn't work for me:

struct MemoryStruct {
          char *memory;
          size_t size;
        };

static void* myrealloc(void *ptr, size_t size)
{
  /* There might be a realloc() out there that doesn't like reallocing
     NULL pointers, so we take care of it here */ 
  if(ptr)
    return realloc(ptr, size);
  else
    return malloc(size);
}

size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void
*data)
{
  size_t realsize = size * nmemb;
  struct MemoryStruct *mem = (struct MemoryStruct *)data;
 
  mem->memory = static_cast<char *>(myrealloc(mem->memory, mem->size +
realsize + 1));
  if (mem->memory) {
    memcpy(&(mem->memory[mem->size]), ptr, realsize);
    mem->size += realsize;
    mem->memory[mem->size] = 0;
  }
  return realsize;
}

void LibcurlImp::GetEventsFromSource()
 {
        CURLcode res;
        std::string strHttpContent = "";
        
        struct MemoryStruct chunk;
        chunk.memory=NULL; /* we expect realloc(NULL, size) to work */ 
        chunk.size = 0;    /* no data at this point */ 

        if(mCurlResult == 0)
        {
                // specify the actual URL to deal with
                curl_easy_setopt(mCurl, CURLOPT_URL,
"http://10.91.345.21/wsman";);

                // set SSH user name and password in libcurl in this
format "user:password"
                curl_easy_setopt(mCurl, 
                                                 CURLOPT_USERPWD,
        
"administrator:q1w2e3r4");

                curl_easy_setopt(mCurl,   CURLOPT_NOPROGRESS  ,1);

                // send all data to this function
                curl_easy_setopt(mCurl, CURLOPT_WRITEFUNCTION,
WriteMemoryCallback);

                /* we pass our 'chunk' struct to the callback function
*/ 
                curl_easy_setopt(mCurl, CURLOPT_WRITEDATA, (void
*)&chunk);

                strHttpContent = "some SOAP query here (which is
perfectly right as it is working with WinHttp calls)";

                // Now specify the POST data
                curl_easy_setopt(mCurl, CURLOPT_POSTFIELDS,
strHttpContent);

                // Perform the request, res will get the return code
                res = curl_easy_perform(mCurl);
         
                // always cleanup
                curl_easy_cleanup(mCurl);
        }
 }

After executing this code, what I get is a blank screen.

But I am expecting the response from the windows server : 10.91.345.21


Thanks & Regards.
Nitin Mittal

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Daniel Stenberg
Sent: Friday, December 04, 2009 5:34 PM
To: libcurl development
Subject: Re: How to prepare a setup for libcurl development

On Thu, 3 Dec 2009, [email protected] wrote:

> Output: Error 12      error LNK2001: unresolved external symbol
> __imp__curl_easy_init wsman.obj

> Preprocessor:
> WIN32;_DEBUG;_CONSOLE;USE_SSLEAY;USE_OPENSSL;-DCURL_STATICLIB

This looks wrong. They are all names but the last one has "-D" prepended
to 
it. The define is named "CURL_STATICLIB", the -D is only for passing the

defien to the compiler.

-- 

  / daniel.haxx.se
-------------------------------------------------------------------
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

Reply via email to