I am trying to establish a connection with remote server for a GET request. Unfortunately on calling
pHttpTransaction = __pHttpSession->OpenTransactionN(); causes exception and the application quits. I am wondering if iI miss some libraries to link or something (added osp-net but no help). HTTP GET Request sample project is working well. How to sort this out?
Attaching the complete code (this is the code in the sample project.
result MainForm::RequestHttpGet(void) { result r = E_SUCCESS; HttpTransaction* pHttpTransaction = null; HttpRequest* pHttpRequest = null; if (__pHttpSession == null) { __pHttpSession = new (std::nothrow) HttpSession(); r = __pHttpSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, HTTP_CLIENT_HOST_ADDRESS, null); if (IsFailed(r)) { delete __pHttpSession; __pHttpSession = null; AppLogException("Failed to create the HttpSession."); goto CATCH; } r = __pHttpSession->SetAutoRedirectionEnabled(true); TryCatch(r == E_SUCCESS, , "Failed to set the redirection automatically."); } pHttpTransaction = __pHttpSession->OpenTransactionN(); r = GetLastResult(); TryCatch(pHttpTransaction != null, , "Failed to open the HttpTransaction."); r = pHttpTransaction->AddHttpTransactionListener(*this); TryCatch(r == E_SUCCESS, , "Failed to add the HttpTransactionListener."); pHttpRequest = const_cast< HttpRequest* >(pHttpTransaction->GetRequest()); r = pHttpRequest->SetUri(HTTP_CLIENT_REQUEST_URI); TryCatch(r == E_SUCCESS, , "Failed to set the uri."); r = pHttpRequest->SetMethod(NET_HTTP_METHOD_GET); TryCatch(r == E_SUCCESS, , "Failed to set the method."); r = pHttpTransaction->Submit(); TryCatch(r == E_SUCCESS, , "Failed to submit the HttpTransaction."); return r; CATCH: delete pHttpTransaction; pHttpTransaction = null; AppLog("RequestHttpGet() failed. (%s)", GetErrorMessage(r)); return r; }