hi,
i am using the sample from by SDK. i have tested the application with the GET method. its working fine. while for POST method. i am getting "data not found. below is my piece of code. whats the wrong with this code. plese some one help.
void CHttpClient::StartClientL()
{
TBuf<256> url;
RStringPool strP = iSess.StringPool();
RStringF method;
//method = strP.StringF(HTTP::EGET,RHTTPSession::GetTable()); // GET
method = strP.StringF(HTTP::EPOST,RHTTPSession::GetTable()); // POST
//iHasARequestBody = EFalse; // for GET
iHasARequestBody = ETrue; // for POST
url = _L("http://192.168.0.65/TestApp/Default.aspx");
//url = _L("http://192.168.0.65/HeadersDisplayApp/printenv.asp");
// Start the method off
TBuf8<256> url8;
url8.Copy(url);
InvokeHttpMethodL(url8, method);
}
void CHttpClient::GetPostBodyManuallyL()
{
if (iFormEncoder)
{
delete iFormEncoder;
iFormEncoder = NULL;
}
iFormEncoder = CHTTPFormEncoder::NewL();
TBuf<256> name;
TBuf<256> value;
TBuf8<256> name8;
TBuf8<256> value8;
name=_L("data");
value = _L("MyTest");
name8.Copy(name);
value8.Copy(value);
iFormEncoder->AddFieldL(name8, value8);
}
void CHttpClient::GetRequestBodyL(RStringF& aMethod)
{
if (aMethod== iSess.StringPool().StringF(HTTP::EPOST,RHTTPSession::GetTable()))
{
iManualPost = ETrue;
GetPostBodyManuallyL();
return;
}
}
void CHttpClient::InvokeHttpMethodL(const TDesC8& aUri, RStringF aMethod)
{
iDataChunkCount = 0;
TUriParser8 uri;
uri.Parse(aUri);
iTrans = iSess.OpenTransactionL(uri, *iTransObs, aMethod);
RHTTPHeaders hdr = iTrans.Request().GetHeaderCollection();
// Add headers appropriate to all methods
SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
SetHeaderL(hdr, HTTP::EAccept, KAccept);
// Add headers and body data for methods that use request bodies
if (iHasARequestBody)
{
// Content type header
TBuf8<64> contTypeBuf;
contTypeBuf.Copy(iReqBodyContentType);
RStringF contTypeStr = iSess.StringPool().OpenFStringL(contTypeBuf);
THTTPHdrVal contType(contTypeStr);
hdr.SetFieldL(iSess.StringPool().StringF(HTTP::EContentType,RHTTPSession::GetTable()), contType);
contTypeStr.Close();
GetRequestBodyL(aMethod);
MHTTPDataSupplier* dataSupplier = this;
dataSupplier = iFormEncoder;
iTrans.Request().SetBody(*dataSupplier);
}
// submit the transaction
iTrans.SubmitL();
CActiveScheduler::Start();
}
thanks in advance.




