cURL / Mailing Lists / curl-library / Single Mail

curl-library

CURLOPT_POST is not returning anything

From: <nitin.mittal_at_rsa.com>
Date: Sun, 13 Dec 2009 23:38:32 -0500

Hi Issac/Jason/lars,

After inputs from all of you, I came up with the following code, but it
still doesn't work for me.

Can you please provide me your inputs/suggestions on this?

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>";
struct curl_slist SOAPaction;
struct curl_slist content_type;

memset(&SOAPaction, 0, sizeof(SOAPaction));
memset(&content_type, 0, sizeof(content_type));

content_type.data = "Content-Type: text/xml";
SOAPaction.data = "SOAPAction: \"\""; /* Empty SOAPAction is the ID-WSF
(and SAML?) standard */

SOAPaction.next = &content_type; //curl_slist_append(3)

curl_easy_setopt(mCurl, CURLOPT_POSTFIELDS, strHttpContent.c_str());

curl_easy_setopt(mCurl, CURLOPT_POSTFIELDSIZE, strHttpContent.length());

//pass headers
curl_easy_setopt(mCurl, CURLOPT_HTTPHEADER, &SOAPaction);
curl_easy_setopt(mCurl, CURLOPT_URL,"http://10.31.251.161:5985/wsman");
FILE * somefile=fopen("somelog.log","w");
curl_easy_setopt(mCurl,CURLOPT_WRITEDATA,somefile);//server response
curl_easy_perform(mCurl);

// always cleanup
curl_easy_cleanup(mCurl);

I am still not able to collect events from the server 10.31.251.161. &
an empty "somelog.log" file is created.

Thanks again for your help.

Regards.
Nitin

        

On Fri, Dec 11, 2009 at 7:01 AM, Isaac Sanni-Thomas
<isaacsannithomas_at_gmail.com> wrote:
>
> On 12/11/2009 11:29 AM, Corcoran, Jason wrote:
>>
>>
>> On Dec 11, 2009, at 3:17 AM, "nitin.mittal_at_rsa.com"
>> <nitin.mittal_at_rsa.com> wrote:
>>
>>> rl_easy_setopt(mCurl, CURLOPT_POSTFIELDSIZE, sizeof(strHttpContent);
>>
>> You need to change the above to
>>
>> rl_easy_setopt(mCurl, CURLOPT_POSTFIELDSIZE,
strHttpContent.length());
>>
>> You are mixing c++ with c stuff.
>
> @Nitin - Yes. Jason is right
>
> So you could get the C++ equiv which Jason states as
strHttpContent.length()
>
> NB://One more thing, after curl_easy_perform() free the headers you
set
> try this too as part of the headers
> struct curl_slist *headers=NULL;
> headers = curl_slist_append(headers, "Content-Type:
Multipart/Related");
> headers = curl_slist_append(headers, "type: text/xml");
>
> curl_easy_perform(mCurl);
> curl_slist_free_all(headers);

Additionally, it may be necessary for the server to receive a header
"SOAPAction:" to get a proper response. SOAP servers can be so picky
sometimes..

Lars Nilsson
-------------------------------------------------------------------
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-14