繁体   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