|
CString strHeaders = _T ("Content-Type: application / x-www-form-urlencoded"); // http protocol
CString strFormData;
strFormData.Format ("UserName =% s, circle);
Ranch
Ranch
CString serverName = _T ("127.0.0.1"); // ip
INTERNET_PORT nPort = 8088; // Port number
CString formAction = _T ("\\web\\Service.jsp");
CInternetSession session;
CHttpConnection * pConnection = session.GetHttpConnection (serverName, nPort);
CHttpFile * pFile = pConnection-> OpenRequest (CHttpConnection :: HTTP_VERB_POST, formAction);
// A fatal error may occur when the server is not open
BOOL result = pFile-> SendRequest (strHeaders, (LPVOID) (LPCTSTR) strFormData, strFormData.GetLength ()); // Send request
Ranch
CString strResult;
pFile-> ReadString (strResult);
strResult.TrimLeft ();
strResult.TrimRight ();
return atoi (strResult);
This code calls pFile-> SendRequest (strHeaders, (LPVOID) (LPCTSTR) strFormData, strFormData.GetLength ()); if the server is not turned on, a fatal error will occur. Ask the expert for a solution to the problem, thank you |
|