'throwing CInternetException for error 12005'

'throwing CInternetException for error 12005'

本文关键字:12005 error throwing CInternetException for      更新时间:2023-10-16

我一直得到"抛出错误 12005 的 CInternetException "

据此,我的网址无效。但是,URL是正确的,我能够访问此SharePoint网站。

我不确定出了什么问题,这是我的代码:

(错误发生在pFile->SendRequest();

void CUserPassDiag::Connect(){
    CInternetSession session(_T("My Session"));
    CHttpConnection* pServer = NULL;
    CHttpFile* pFile = NULL;
    try
    {
        CString strServerName = _T("http://collaboration.unc.ca");
        CString headers = "Content-Type: application/x-www-form-urlencodedrn";
        headers += "Host: xcollaboration.pwc.carn";
        headers += "Method: POSTrn";
        headers += "Pragma: no-cachern";
        headers += "Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, *//*rn";
        CString szHeaders = _T("%s",headers);
        //To Be Send    
        CString strFormData  = _T("action=setCameraSetting&videoOverlay.useTimestamp=1&videoOverlay.useText=1&videoOverlay.displayString=12.12-77.32");
        DWORD dwRet;
        CString strObject = _T("/team/T5342DFG/SitePages/UNCHome.aspx");
        pServer = session.GetHttpConnection(strServerName, INTERNET_DEFAULT_HTTP_PORT, _T(""), _T(""));
        pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST, strObject);
        pFile->AddRequestHeaders(szHeaders);
        pFile->SendRequest();
        pFile->QueryInfoStatusCode(dwRet);
        TRACE("%d",dwRet);
        delete pFile;
        delete pServer;
    }catch(CInternetException* e){
        TCHAR sz[1024];
        e->GetErrorMessage(sz,1024);
        _tprintf_s(_T("ERROR!  %sn"), sz);
        e->Delete();
    }
  session.Close();
}

服务器名称 ( strServerName ) 不应包含 http:// 前缀 - 它应该只是服务器的域名(或 IP 地址)。