Discussion Board
WAP Connection and getting data
2003-11-06, 10:00
#1
Registered User
Hi All,
I have read all the question about WAP connection in the forum nokia, and I have tried the diffrent codes that have been posted.
But am still not getting any data back.
Am checking which event I am getting back and its a : "EResume_cnf_s"... I don't know what that event means ??
Can any one help ?? PLEASE !!!!!!!!!!!!!!
Here is my code :
RGenericAgent agent;
User::LeaveIfError(agent.Open());
User::LeaveIfError(agent.StartOutgoing());
//Connect to the Symbian OS WAP server
RWAPServ server;
User::LeaveIfError(server.Connect());
//Initialize a connection to the WAP gateway
RWSPCOConn connection;
// host contains the IP address of the wap gw
// TInt Open(RWAPServ& aServer, const TDesC8& aRemoteHost,
// TPort aRemotePort, TPort aLocalPort,
// TBearer aBearer, TBool aSecureConn);
_LIT8(HOST, "192.168.71.35");
User::LeaveIfError(connection.Open(server, HOST, 9201, 0, EIP, EFalse));
_LIT8(KClientHeaders, "text/plain");
TInt connectionError = connection.Connect(KClientHeaders, 0);
RWSPCOTrans transaction;
_LIT(URI, "http://localhost:8080/Wap/servlet/DeviceLocation");
if (connectionError == 0 )
{
_LIT8(KClientBody, "username=djazia&password=pwd&method=method");
TInt transactionError = connection.CreateTransaction(
RWAPConn::EPost, URI, KClientHeaders,
KClientBody, transaction);
if(transactionError == 0)
{
HBufC8* buffer;
buffer = HBufC8::NewLC(200);
TPtr8 ptr = buffer->Des();
User::After(1000000);
TInt eventCode;
RWSPCOConn::TEvent event;
TRequestStatus status;
eventCode = connection.GetEvent(event, transaction);
switch(event() )
{
//... all the different cases
case RWSPCOConn::EResume_cnf_s:
{
CAknInformationNote* note = new(ELeave) CAknInformationNote; TBuf<BUFF_SIZE> buf(_L("EResume_cnf_s"));
note->ExecuteLD(buf);
}
break;
TInt getDataError = transaction.GetData(ptr, RWSPCOTrans::EResultBody);
if(getDataError == 0)
{
Parse(ptr);
CleanupStack::PopAndDestroy();// capCodec, buffer
transaction.Release();
connection.Close();
server.Close();
}
else // Get data
{
CAknInformationNote* note = new(ELeave) CAknInformationNote;
TBuf<BUFF_SIZE> buf(_L("GET DATA ERROR"));
note->ExecuteLD(buf);
}
}else // transaction
{
TBuf<BUFF_SIZE> buf(_L("TRANSACTION ERROR"));
CAknInformationNote* note = new(ELeave) CAknInformationNote;
note->ExecuteLD(buf);
}
}else // Connection
{
TBuf<BUFF_SIZE> buf(_L("CONNECTION ERROR"));
CAknInformationNote* note = new(ELeave) CAknInformationNote;
note->ExecuteLD(buf);
}
}
Note : the Parse() method parses the buffer and gets the information within this buffer.
For now I am just diplaying the content of this buffer. But this one is always empty. Maybe I am doing smth wrong in this method:
void CWAPConnectionView::Parse(TDesC8& aBuffer)
{
TBuf<1000> myBuffer;
myBuffer.Copy(aBuffer);
TBuf<BUFF_SIZE> test;
test.Append(_L("data back: "));
test.Append(myBuffer);
CAknInformationNote* note = new(ELeave) CAknInformationNote;
note->ExecuteLD(test);
}
Thanks for your help,
Djazia
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules