Unicode C++
Unicode C++
Transition from Http.PostXml to Http.HttpStr
Provides instructions for replacing deprecated PostXml method calls with HttpStr.Chilkat Unicode C++ Downloads
#include <CkHttpW.h>
#include <CkHttpResponseW.h>
void ChilkatSample(void)
{
bool success = false;
CkHttpW http;
const wchar_t *url = L"https://example.com/something";
const wchar_t *requestBodyXml = L"<something>...</something>";
const wchar_t *charset = L"utf-8";
// ------------------------------------------------------------------------
// The PostXml method is deprecated:
CkHttpResponseW *responseObj = http.PostXml(url,requestBodyXml,charset);
if (http.get_LastMethodSuccess() == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
// ...
// ...
delete responseObj;
// ------------------------------------------------------------------------
// Do the equivalent using HttpStr.
// Your application creates a new, empty HttpResponse object which is passed
// in the last argument and filled upon success.
CkHttpResponseW responseOut;
success = http.HttpStr(L"POST",url,requestBodyXml,charset,L"application/xml",responseOut);
if (success == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
}