向服务器发送消息
春华-秋实 2012-12-20 11:23:00 调用winhttpsendrequest 向服务器发送一段数据,显示发送成功,可是服务器这边接收到的值为null,请高人指点。
如下:
CrackedUrl crackedUrl(L"http://localhost:8080/temp/TestService");//服务器连接地址
CStringA strPostData("param = test");//测试数据
if (!SendRequest(hRequest, (const char*)strPostData, strPostData.GetLength())) {//发送数据到服务
printf("Error:SendRequest failed!/n");//器,若失败,则打印该消息。
return -1;
}
SendRequest 里面调用的就是winhttpsendrequest 函数:
BOOL SendRequest(HINTERNET hRequest, const void* body, DWORD size)
{
return WinHttpSendRequest(hRequest, 0, 0, const_cast<void*>(body), size, size, 0);
}
调用winhttpsendrequest后,显示发送成功,但服务器接收为null,不明白,真心求教。