#include "stdafx.h"
char * main(int argc, char* argv[])
{
HINTERNET hNet = InternetOpen("211.139.191.180",PRE_CONFIG_INTERNET_ACCESS,NULL,INTERNET_INVALID_PORT_NUMBER,0) ;
assert(hNet);
HINTERNET hConnect = InternetConnect(hNet,"211.139.191.180",INTERNET_INVALID_PORT_NUMBER,
"","",INTERNET_SERVICE_HTTP,0,0);
assert(hConnect);
//HINTERNET hHttpFile = HttpOpenRequest(hConnect,"POST","http://211.139.191.180:2082/sso/misc_sso_icp.js",HTTP_VERSION,NULL,0,
//INTERNET_FLAG_DONT_CACHE,0);
HINTERNET hHttpFile = HttpOpenRequest(hConnect, "POST", "http://211.139.191.180:2082/sso/misc_sso_icp.js", NULL,
NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
assert(hHttpFile); char xmldoc[1024];
memset(xmldoc,0,sizeof(xmldoc));
strcpy(xmldoc, "<?xml version = \"1.0\" ?>");
strcat(xmldoc,"<misc_command version= \"1.5\" >");
strcat(xmldoc,"<command_name>sso</command_name>");
strcat(xmldoc,"<command_data_block>");
strcat(xmldoc,"<sid>");
strcat(xmldoc,"111");
strcat(xmldoc,"</sid>");
strcat(xmldoc,"<service_id>");
strcat(xmldoc,"222");
strcat(xmldoc,"</service_id>");
strcat(xmldoc,"<sp_id>");
strcat(xmldoc,"1111111");
strcat(xmldoc,"</sp_id>");
strcat(xmldoc,"<sp_password>");
strcat(xmldoc,"22222222");
strcat(xmldoc,"</sp_password>");
strcat(xmldoc,"</command_data_block>");
strcat(xmldoc,"</misc_command>");
BOOL bSendRequest = ::HttpSendRequest(hHttpFile,NULL,0,(void *)xmldoc,(DWORD)sizeof(xmldoc));
//HttpSendRequest(hHttpFile,NULL,0,xmldoc); //////////////////////////////////////////////////////////
// Get the length of the file.
char bufQuery[32] ;
DWORD dwLengthBufQuery = sizeof(bufQuery);
BOOL bQuery = (hHttpFile,HTTP_QUERY_CONTENT_LENGTH,bufQuery,&dwLengthBufQuery,0);
// Convert length from ASCII string to a DWORD.
DWORD dwFileSize = (DWORD)atol(bufQuery) ;
//printf("%d\n",&dwFileSize);
// Allocate a buffer for the file.
char* buffer;
buffer = (char*)malloc(sizeof(char*));
memset(buffer,0,sizeof(buffer));
// Read the file into the buffer.
DWORD dwBytesRead ; BOOL bRead = InternetReadFile(hHttpFile,buffer,5000,&dwBytesRead);
buffer[strlen(buffer)] = '\0';
printf("%s\n",buffer);
// Put a zero on the end of the buffer.
buffer[dwBytesRead] = 0 ;
// Close all of the Internet handles.
InternetCloseHandle(hHttpFile);
InternetCloseHandle(hConnect) ;
InternetCloseHandle(hNet) ;
return NULL;
}
以上我向一个URL提交了一个xml文档,它却没有回复数据,但是我使用GET就可以了。,不知道为什么,我个人认为问题出在HttpSendRequest(),望有做过HTTP的兄弟多多指教。谢谢
char * main(int argc, char* argv[])
{
HINTERNET hNet = InternetOpen("211.139.191.180",PRE_CONFIG_INTERNET_ACCESS,NULL,INTERNET_INVALID_PORT_NUMBER,0) ;
assert(hNet);
HINTERNET hConnect = InternetConnect(hNet,"211.139.191.180",INTERNET_INVALID_PORT_NUMBER,
"","",INTERNET_SERVICE_HTTP,0,0);
assert(hConnect);
//HINTERNET hHttpFile = HttpOpenRequest(hConnect,"POST","http://211.139.191.180:2082/sso/misc_sso_icp.js",HTTP_VERSION,NULL,0,
//INTERNET_FLAG_DONT_CACHE,0);
HINTERNET hHttpFile = HttpOpenRequest(hConnect, "POST", "http://211.139.191.180:2082/sso/misc_sso_icp.js", NULL,
NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
assert(hHttpFile); char xmldoc[1024];
memset(xmldoc,0,sizeof(xmldoc));
strcpy(xmldoc, "<?xml version = \"1.0\" ?>");
strcat(xmldoc,"<misc_command version= \"1.5\" >");
strcat(xmldoc,"<command_name>sso</command_name>");
strcat(xmldoc,"<command_data_block>");
strcat(xmldoc,"<sid>");
strcat(xmldoc,"111");
strcat(xmldoc,"</sid>");
strcat(xmldoc,"<service_id>");
strcat(xmldoc,"222");
strcat(xmldoc,"</service_id>");
strcat(xmldoc,"<sp_id>");
strcat(xmldoc,"1111111");
strcat(xmldoc,"</sp_id>");
strcat(xmldoc,"<sp_password>");
strcat(xmldoc,"22222222");
strcat(xmldoc,"</sp_password>");
strcat(xmldoc,"</command_data_block>");
strcat(xmldoc,"</misc_command>");
BOOL bSendRequest = ::HttpSendRequest(hHttpFile,NULL,0,(void *)xmldoc,(DWORD)sizeof(xmldoc));
//HttpSendRequest(hHttpFile,NULL,0,xmldoc); //////////////////////////////////////////////////////////
// Get the length of the file.
char bufQuery[32] ;
DWORD dwLengthBufQuery = sizeof(bufQuery);
BOOL bQuery = (hHttpFile,HTTP_QUERY_CONTENT_LENGTH,bufQuery,&dwLengthBufQuery,0);
// Convert length from ASCII string to a DWORD.
DWORD dwFileSize = (DWORD)atol(bufQuery) ;
//printf("%d\n",&dwFileSize);
// Allocate a buffer for the file.
char* buffer;
buffer = (char*)malloc(sizeof(char*));
memset(buffer,0,sizeof(buffer));
// Read the file into the buffer.
DWORD dwBytesRead ; BOOL bRead = InternetReadFile(hHttpFile,buffer,5000,&dwBytesRead);
buffer[strlen(buffer)] = '\0';
printf("%s\n",buffer);
// Put a zero on the end of the buffer.
buffer[dwBytesRead] = 0 ;
// Close all of the Internet handles.
InternetCloseHandle(hHttpFile);
InternetCloseHandle(hConnect) ;
InternetCloseHandle(hNet) ;
return NULL;
}
以上我向一个URL提交了一个xml文档,它却没有回复数据,但是我使用GET就可以了。,不知道为什么,我个人认为问题出在HttpSendRequest(),望有做过HTTP的兄弟多多指教。谢谢
HTTP Error 404: The requested document was not found
The document you requested does not exist at this site