简体   繁体   中英

'throwing CInternetException for error 12005'

I keep getting "throwing CInternetException for error 12005"

According to this , my URL is invalid. However the URL is correct and i am able to access this SharePoint site.

I am not sure what is wrong, here is my code:

(the error occurs at 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-urlencoded\r\n";
        headers += "Host: xcollaboration.pwc.ca\r\n";
        headers += "Method: POST\r\n";
        headers += "Pragma: no-cache\r\n";
        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, *//*r\n";

        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!  %s\n"), sz);
        e->Delete();
    }
  session.Close();

}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM