Iulia
2008-05-07 15:58:00 UTC
Hello.
Please, I would really need some help with wininet functions. I have a
project in Visual Studio 2005 that uses the Visual Studio’s server. When it
is executing, it listens on the 7000 port at the address:
http://www.fabrikam.com:7000/sample/trust/usernamepassword/sts . I can target
this address with telnet.
The important parts of my code are:
//******** code beginning ********
//req_token is a string I want to send as a message atached to a POST request
HINTERNET internet_open = InternetOpen(_T("cardspace-proxy"),
INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
HINTERNET internet_connect = InternetConnect(internet_open,
"www.fabrikam.com", 7000, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
char *types=(char*)malloc(strlen("application/soap+xml") + 2);
strcpy(types,"application/soap+xml");
types[strlen("application/soap+xml") + 1 ] = 0;
HINTERNET open_request = HttpOpenRequest(internet_connect, "POST",
"/sample/trust/usernamepassword/sts", "HTTP/1.1", NULL, (const char**)
&types, INTERNET_FLAG_RELOAD, NULL);
char buf[7];
sprintf(buf,"%d",req_tok.length());
string header = "Content-Type: application/soap+xml; charset=utf-8; Host:
www.fabrikam.com:7000; Content-Length: ";
header += buf;
header += "; Expect: 100-continue";
if ( !HttpSendRequest( open_request, header.c_str(), header.length(),
(void*)req_tok.c_str(), req_tok.length()) )
{…}
if ( !HttpQueryInfo (open_request, HTTP_QUERY_STATUS_CODE, szSatusCode,
&dwInfoBufferSize, NULL) )
{…}
if( !InternetQueryDataAvailable( open_request,&dwNumberOfBytesAvailable, 0,
0) )
{…}
if( !InternetReadFile( open_request, lpBuffer, dwNumberOfBytesAvailable,
&dwNumberOfBytesRead))
{…}
//******** code end ********
The error is: “HttpSendRequest failed; Error: 12002”. I searched and 12002
means that the request has timed out. I really don’t understand why it
doesn’t work.
Thank you.
Iulia
Please, I would really need some help with wininet functions. I have a
project in Visual Studio 2005 that uses the Visual Studio’s server. When it
is executing, it listens on the 7000 port at the address:
http://www.fabrikam.com:7000/sample/trust/usernamepassword/sts . I can target
this address with telnet.
The important parts of my code are:
//******** code beginning ********
//req_token is a string I want to send as a message atached to a POST request
HINTERNET internet_open = InternetOpen(_T("cardspace-proxy"),
INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
HINTERNET internet_connect = InternetConnect(internet_open,
"www.fabrikam.com", 7000, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
char *types=(char*)malloc(strlen("application/soap+xml") + 2);
strcpy(types,"application/soap+xml");
types[strlen("application/soap+xml") + 1 ] = 0;
HINTERNET open_request = HttpOpenRequest(internet_connect, "POST",
"/sample/trust/usernamepassword/sts", "HTTP/1.1", NULL, (const char**)
&types, INTERNET_FLAG_RELOAD, NULL);
char buf[7];
sprintf(buf,"%d",req_tok.length());
string header = "Content-Type: application/soap+xml; charset=utf-8; Host:
www.fabrikam.com:7000; Content-Length: ";
header += buf;
header += "; Expect: 100-continue";
if ( !HttpSendRequest( open_request, header.c_str(), header.length(),
(void*)req_tok.c_str(), req_tok.length()) )
{…}
if ( !HttpQueryInfo (open_request, HTTP_QUERY_STATUS_CODE, szSatusCode,
&dwInfoBufferSize, NULL) )
{…}
if( !InternetQueryDataAvailable( open_request,&dwNumberOfBytesAvailable, 0,
0) )
{…}
if( !InternetReadFile( open_request, lpBuffer, dwNumberOfBytesAvailable,
&dwNumberOfBytesRead))
{…}
//******** code end ********
The error is: “HttpSendRequest failed; Error: 12002”. I searched and 12002
means that the request has timed out. I really don’t understand why it
doesn’t work.
Thank you.
Iulia