I am developing an asynchronous WAP client(using SDK V1.2),i am able to send the request to the server and get the response,the problem is, i am able to send only 5 to 8 times. after that, DOCancel method is been called automatically.
when i close the transaction(each time) it returns the error code RWSPCOConn::EInvalidTransaction -5473.
I have given my code below.Any help would be really appreciable.

Regards,
Parthi


void CWapEngine:oCancel()
{
file.Write(_L8("DoCancel"));
connection.CancelGetEvent();
}

void CWapEngine::ReleaseTx()
{
//TState& aState;
file.Write(_L8("ReleaseTx"));
// if (!iTxOpen) return;

TInt iState ;

iState = transaction.Release();

file.Write(_L8("teans-release state = "));
TBuf8<20> state;
state.AppendNum(iState);
file.Write(state);
//iState = transaction.GetState(aState);
// iTxOpen=false;
}

void CWapEngine::ReleaseConn()
{
file.Write(_L8("ReleaseConn"));
// if (!iConnOpen) return;
connection.Close();
// iConnOpen=false;
}

void CWapEngine::RunL()
{
file.Write(_L8("RunL"));
TBuf<50> msg;
if (iStatus!=KErrNone)
{
file.Write(_L8("KErrNone"));
if (current_state==TX)
{
file.Write(_L8("TX if"));
RWSPCOConn::TSessionState s;
connection.GetSessionState(s);
msg.Format(_L("Conn state %d, error %d"),
TInt(s), iStatus);
}
else
{
file.Write(_L8("TX else"));
msg.Format(_L("error %d"), iStatus.Int());
}
//observer.error(this, iStatus.Int(), msg);
return;
}

TBuf8<100> msg8;
switch (current_state)
{
file.Write(_L8("current_state"));
case CONNECTING:
file.Write(_L8("CONNECTING"));
break;
case TX:
file.Write(_L8("TX"));
if(event() == RWSPCOConn::EDisconnect_ind_s ||event() == RWSPCOConn::EException_ind_e ||
event() == RWSPCOConn::ERedirect_ind_s ||event() == RWSPCOConn::ESuspend_ind_s)
{
file.Write(_L8("TX error"));
}
else if(event() == RWSPCOConn::EConnect_cnf_s)
{
TBuf8<20> header;
header.Append(_L8("\x80")); header.Append(_L8("\x80"));
if(connection.CreateTransaction(RWAPConn::EGet,iHost,header,_L8(""),event_tx) == KErrNone)
{
connection.GetEvent(event, event_tx, iStatus);
SetActive();
current_state=CONNECTED;
}
}
break;

case CONNECTED:
file.Write(_L8("CONNECTED"));
if(event() == RWSPCOConn::EAbort_ind_t ||event() == RWSPCOConn::EException_ind_e)
{
file.Write(_L8("CONNECTED error"));
}
else if(event() == RWSPCOConn::EMethodResult_ind_t)
{
file.Write(_L8("CONNECTED recv"));
do
{
file.Write(_L8("CONNECTED loop"));
TBuf8<2048> data;
ret = event_tx.GetData(data, RWSPCOTrans::EResultBody);
file.Write(data);
Close();
iBarcodeAppUi.ResponseReceived(data);

break;
}while(ret == RWAPConn::EMoreData);
}
else
{
file.Write(_L8("CONNECTED else"));
connection.GetEvent(event, event_tx, iStatus);
SetActive();
current_state=CONNECTED;
}


break;

case RESULT_OK_WAIT:
file.Write(_L8("RESULT_OK_WAIT"));
break;

default:
file.Write(_L8("default"));
break;
}
return;
}

void CWapEngine::ConstructL()
{

CActiveScheduler::Add(this);
fs.Connect();
User::LeaveIfError(file.Replace(fs, _L("c:\\wap.txt"), EFileWrite|EFileShareAny));
}

CWapEngine::~CWapEngine()
{
Cancel();

file.Close();
fs.Close();


if (iCap)
{
//iCap->Reset();
delete iCap;
}

// ReleaseTx();
// ReleaseConn();


}

//initiate WAP connection
void CWapEngine::Connect(/*TUint32 IapID,*/ const TDesC& UrlBase)
{
file.Write(_L8("Connect"));
iHost=UrlBase;

current_state=CONNECTING;

_LIT8(headers, "");

TBuf8<20> header;

header.Append(_L8("\x80")); header.Append(_L8("\x80"));

TBuf8<100> host;

if (server.Connect() == KErrNone)
{
if (!iCap)
iCap = CCapCodec::NewL();
iCap->SetServerSDUSize(/*MAXSIZE+3000*/150000);
iCap->SetClientSDUSize(/*MAXSIZE+3000*/150000);


// setup gateway connection info
host.Copy(_L8("66.36.250.14"));
TInt port=9201;
if (connection.Open(server, host, port, 0, EIP, EFalse) == KErrNone)
{
iConnOpen=true;
TInt ret;
if (ret=connection.Connect(headers, iCap) == KErrNone)
{
connection.GetEvent(event, event_tx, iStatus);
SetActive();
current_state=TX;
file.Write(_L8("Connect end"));
}
}
}
}

void CWapEngine::Close()
{
file.Write(_L8("Close"));

ReleaseTx();
ReleaseConn();
server.Close();

// Cancel();
}