簡體   English   中英

'將CInternetException拋出錯誤12005'

[英]'throwing CInternetException for error 12005'

我不斷收到“錯誤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-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地址)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM