Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
38 Points
10 Posts
Oct 18, 2010 12:21 PM|LINK
Hello
I want to connect WCF service ("https://sandbox-wbapi.thesslstore.com/WBService.svc") with use of c++ and curl.
But i cannot get response from API means i could not connect the service.
I used following code snippet.
#include <iostream> #include <curl/curl.h> using namespace std; inline static int WriteToString(char* ptr, size_t size, size_t nmemb, string* str) { return str ? str->append(ptr, size * nmemb), size * nmemb : 0; } int main(int argc, char **argv) { string request("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" " "xmlns:a=\"http://www.w3.org/2005/08/addressing\" " "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" "<s:Header>" "<a:Action s:mustUnderstand=\"1\">https://sandbox-wbapi.thesslstore.com/WBService/ValidateResellerCredential" "</a:Action>" "<a:To s:mustUnderstand=\"1\">https://sandbox-wbapi.thesslstore.com/WBService.svc</a:To>" "</s:Header>" "<s:Body>" "<ValidateResellerCredential xmlns=\"https://sandbox-wbapi.thesslstore.com/\">" "<objAuth>" "<PartnerCode>82911347</PartnerCode>" "<ResellerPassword>a4w364h6</ResellerPassword>" "<ResellerUserName>azvoznikov@ya.ru</ResellerUserName>" "</objAuth>" "</ValidateResellerCredential>" "</s:Body>" "</s:Envelope>"); struct curl_slist *headerlist = NULL; headerlist = curl_slist_append(headerlist, "Content-Type: application/soap+xml; charset=utf-8"); headerlist = curl_slist_append(headerlist, "https://sandbox-wbapi.thesslstore.com/WBService/ValidateResellerCredential"); CURL *curl; curl = curl_easy_init(); CURLcode res = (CURLcode)1; string result; curl_easy_setopt(curl, CURLOPT_URL, "https://sandbox-wbapi.thesslstore.com/WBService.svc"); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 1L); curl_easy_setopt(curl, CURLOPT_POST, 1L); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, request.c_str()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteToString); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &result); res = curl_easy_perform(curl); if (res != CURLE_OK) printf("Curl return error: %s", string(curl_easy_strerror(res)).c_str()); printf("\n%s", result.c_str()); return 0; }
Help me to resolve this issue.
WCF c++ Curl
Kaushal P
Member
38 Points
10 Posts
Failed to connect wcf service using C++ and Curl
Oct 18, 2010 12:21 PM|LINK
Hello
I want to connect WCF service ("https://sandbox-wbapi.thesslstore.com/WBService.svc") with use of c++ and curl.
But i cannot get response from API means i could not connect the service.
I used following code snippet.
#include <iostream> #include <curl/curl.h> using namespace std; inline static int WriteToString(char* ptr, size_t size, size_t nmemb, string* str) { return str ? str->append(ptr, size * nmemb), size * nmemb : 0; } int main(int argc, char **argv) { string request("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" " "xmlns:a=\"http://www.w3.org/2005/08/addressing\" " "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" "<s:Header>" "<a:Action s:mustUnderstand=\"1\">https://sandbox-wbapi.thesslstore.com/WBService/ValidateResellerCredential" "</a:Action>" "<a:To s:mustUnderstand=\"1\">https://sandbox-wbapi.thesslstore.com/WBService.svc</a:To>" "</s:Header>" "<s:Body>" "<ValidateResellerCredential xmlns=\"https://sandbox-wbapi.thesslstore.com/\">" "<objAuth>" "<PartnerCode>82911347</PartnerCode>" "<ResellerPassword>a4w364h6</ResellerPassword>" "<ResellerUserName>azvoznikov@ya.ru</ResellerUserName>" "</objAuth>" "</ValidateResellerCredential>" "</s:Body>" "</s:Envelope>"); struct curl_slist *headerlist = NULL; headerlist = curl_slist_append(headerlist, "Content-Type: application/soap+xml; charset=utf-8"); headerlist = curl_slist_append(headerlist, "https://sandbox-wbapi.thesslstore.com/WBService/ValidateResellerCredential"); CURL *curl; curl = curl_easy_init(); CURLcode res = (CURLcode)1; string result; curl_easy_setopt(curl, CURLOPT_URL, "https://sandbox-wbapi.thesslstore.com/WBService.svc"); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 1L); curl_easy_setopt(curl, CURLOPT_POST, 1L); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, request.c_str()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteToString); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &result); res = curl_easy_perform(curl); if (res != CURLE_OK) printf("Curl return error: %s", string(curl_easy_strerror(res)).c_str()); printf("\n%s", result.c_str()); return 0; }Help me to resolve this issue.
WCF c++ Curl
SSL Certificates