cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: CURLOPT_POST is not returning anything

From: Isaac Sanni-Thomas <isaacsannithomas_at_gmail.com>
Date: Fri, 11 Dec 2009 10:25:29 +0000

On 12/11/2009 10:04 AM, nitin.mittal_at_rsa.com wrote:
> Thanks for your reply. Really appreciate that.
>
> I have tried your way but I am still getting nothing.
>
> The only difference in my code& the one which you sent is in the lines:
>
> curl_easy_setopt(handle, CURLOPT_POSTFIELDS,"PIN=0&data=510000");
>
> curl_easy_setopt(handle, CURLOPT_URL,"http://localhost/sub/test2.php");
>
> In my code, I have replaced these lines with the lines below:
>
> curl_easy_setopt(handle, CURLOPT_POSTFIELDS, strHttpContent);
> curl_easy_setopt(handle, CURLOPT_URL,"http://10.91.243.23:5985/wsman");
>
>
> Where strHttpContent is containg a SOAP query as shown below:
>
> std::string strHttpContent="<s:Envelope
> xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"
> xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\"
> xmlns:e=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\"
> xmlns:n=\"http://schemas.xmlsoap.org/ws/2004/09/enumeration\"
> xmlns:w=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\"><s:Header><a:
> To>http://10.31.251.161:5985/wsman</a:To><w:ResourceURI
> s:mustUnderstand=\"true\">http://schemas.microsoft.com/wbem/wsman/1/wind
> ows/EventLog</w:ResourceURI><a:ReplyTo><a:Address
> s:mustUnderstand=\"true\">http://schemas.xmlsoap.org/ws/2004/08/addressi
> ng/role/anonymous</a:Address></a:ReplyTo><a:Action
> s:mustUnderstand=\"true\">http://schemas.xmlsoap.org/ws/2004/08/eventing
> /Subscribe</a:Action><w:MaxEnvelopeSize
> s:mustUnderstand=\"true\">153600</w:MaxEnvelopeSize><a:MessageID>" +
> strFormatName + "</a:MessageID><w:Locale xml:lang=\"en-US\"
> s:mustUnderstand=\"false\" /><w:OptionSet
> xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><w:Option
> Name=\"SubscriptionName\">RSAenVision</w:Option><w:Option
> Name=\"ContentFormat\">RenderedText</w:Option><w:Option
> Name=\"ReadExistingEvents\" xsi:nil=\"true\"/><w:Option
> Name=\"IgnoreChannelError\"
> xsi:nil=\"true\"/></w:OptionSet><w:OperationTimeout>PT60.000S</w:Operati
> onTimeout></s:Header><s:Body><e:Subscribe><e:Delivery
> Mode=\"http://schemas.dmtf.org/wbem/wsman/1/wsman/Pull\"><w:Heartbeats>P
> T2000.000S</w:Heartbeats><w:Locale
> xml:lang=\"en-US\"/><w:ContentEncoding>UTF-8</w:ContentEncoding></e:Deli
> very><w:Filter
> Dialect=\"http://schemas.microsoft.com/win/2004/08/events/eventquery\"><
> QueryList><Query Id=\"0\"><Select Path=\"Application\">*</Select><Select
> Path=\"System\">*</Select><Select
> Path=\"Security\">*</Select></Query></QueryList></w:Filter><w:SendBookma
> rks/></e:Subscribe></s:Body></s:Envelope>";
>
>
> Can you please suggest something now?

Set the headers for soap to something like this:

struct curl_slist *headers=NULL;
headers = curl_slist_append(headers, "Content-Type: text/xml");

  //add content of postfield
curl_easy_setopt(handle, CURLOPT_POSTFIELDS, strHttpContent);

  //size of postfield data.in C u can do sizeof(strHttpContent)
curl_easy_setopt(handle, CURLOPT_POSTFIELDSIZE, 45L);

  //pass headers
  curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);

FILE * somefile=fopen("somelog.log","w");
curl_easy_setopt(handle,CURLOPT_WRITEDATA,somefile);//server response
curl_easy_perform(handle);

Try this and tell us how it goes.

regards.
Isaac
> Thanks once again!
>
> Regards.
> Nitin
>
> -----Original Message-----
> From: curl-library-bounces_at_cool.haxx.se
> [mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of Isaac
> Sanni-Thomas
> Sent: Friday, December 11, 2009 3:16 PM
> To: curl-library_at_cool.haxx.se
> Subject: Re: CURLOPT_POST is not returning anything
>
>
> On 12/11/2009 09:19 AM, nitin.mittal_at_rsa.com wrote:
>> Thanks for your reply.
>>
>> I ave removed CURLOPT_POSTFIELDS& kept only CURLOPT_READFUNCTION.
>>
>> But even then I am not getting any response from the server.
>>
>> I want read_callback to read the respose that will be sent back by the
>> server (which I am not getting right now& that's the problem).
>
> So what you want to do is to get the response from the server and
> process that response. I write the response to a file and then read back
>
> for some other processing like this:
>
> //All Code in C
> curl_easy_setopt(handle, CURLOPT_POSTFIELDS,"PIN=0&data=510000");
> curl_easy_setopt(handle, CURLOPT_URL,"http://localhost/sub/test2.php");
> FILE * somefile=fopen("somelog.log","w");
> curl_easy_setopt(handle,CURLOPT_WRITEDATA,somefile);//server response
> curl_easy_perform(handle);
>
> That will write the web server response to the file somelog.log.
> From here I have another line where I read the server response in the
> file and process accordingly by my app.
> NB://Ensure that your web app works correctly without errors.
> Hope this helps.
>> I found this read_callback implementation while digging through the
>> links on net& pasted it as I found it. I can modify this function
> later
>> but I should get at least some response from the server. I am getting
> a
>> blank screen instead.
>>
>> I hope you undertstand the problem now.
>>
>> Thanks& Regards,
>> Nitin Mittal
>> -----Original Message-----
>> From: curl-library-bounces_at_cool.haxx.se
>> [mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of Daniel
> Stenberg
>> Sent: Friday, December 11, 2009 2:20 PM
>> To: libcurl development
>> Subject: Re: CURLOPT_POST is not returning anything
>>
>> On Thu, 10 Dec 2009, nitin.mittal_at_rsa.com wrote:
>>
>>> I am able to connect to the remote server but in return I am just
>> getting
>>> the blank screen. I expect the server to send some response.
>>>
>>> Am I missing any libcurl call or anything?
>>
>> I suggest starting out with an example code and go from there.
>>
>> You use both read callback and postfields, what exactly do you want
> the
>> read
>> callback for and if you want it, why do you make it read only one byte
>> at a
>> time?
>>
>>
>>
>>
>> -------------------------------------------------------------------
>> 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
>
> -------------------------------------------------------------------
> 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 2009-12-11