×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    31

    WAP connectivity

    Hi everyone,

    Does anyone have a sample project on establishing a WAP session to download a file using EPOC's WAP server using the WAP stack APIs. I am using Nokia WAP Gateway simulator. I have studied the WAP Stack APIs and implemented some code found on this forum but it just simply runs without producing any message on the console window of the Gateway or its log files.
    Help is badly needed. Thanks in advance.....


    Nishant

  2. #2
    Registered User
    Join Date
    Aug 2003
    Location
    Oulu, Finland
    Posts
    1,122
    It would be most helpful if you told what you've already tried to do.

    - Do you have the RAS connectivity set up for the emulator? (Null modem cable or virtual serial port driver and an Windows incoming connection or mRouterLite). Can you use the browser on the emulator if you configure the NT RAS access point to have your IP address as the WAP gateway?

    - Do you have an outgoing connection set up using RGenericAgent or CIntConnectionInitiator?

    - Are you connecting to the right gateway IP address? It should be the external interface address (use ipconfig to see it) and not a loopback interface address 127.0.0.1.

    Lauri

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    31
    Hi Lauri,

    Thanks for the prompt reply.

    No, I don't have RAS connectivity set up for the emulator. How to do that? As of now, I have Nokia WAP Gateway simulator running on my machine in which I have configured the IP address of the Internet Proxy server( since I working on a LAN). I run Nokia Mobile browser simulator and I am able to access wml pages hosted on internet like wap.yahoo.com or on my local webserver(within my LAN).

    The job is to somehow download a file on the Webserver and place it in the filesystem of EPOC emulator through WAP.

    The code I have implemented so far is:

    RWAPServ handle_EPOC_WAP_Server;
    RWSPCOConn test_CO_wsp_session;
    RWSPCOTrans WSPTransaction;

    _LIT8(WapGateway, "132.186.198.103");
    // IP of the WAP gateway on my machine

    _LIT8(ClientHeaders, "test");
    _LIT(URL, "http://132.186.198.103/index.wml");
    _LIT8(Body, "test");

    RWAPConn::TPort RemotePort = 8201;
    RWAPConn::TPort LocalPort = 0;
    TInt err;
    TBearer Bearer = EIP;
    TBool SecureConn = EFalse; //ALWAYS!!!
    RWAPConn::TMethod imethod = RWAPConn::EGet;

    TVersion ver = handle_EPOC_WAP_Server.Version();
    switch(ver.iMajor)
    {
    case 0:
    break;
    };

    err = -1;
    err = handle_EPOC_WAP_Server.Connect();
    switch(err)
    {
    case 0:
    break;
    };

    err = -1;
    err = test_CO_wsp_session.Open(handle_EPOC_WAP_Server, WapGateway, RemotePort, LocalPort, Bearer, SecureConn);
    switch(err)
    {
    case 0:
    break;
    };

    err = -1;
    err = test_CO_wsp_session.Connect(ClientHeaders,0); // 0 for default capabilities
    switch(err)
    {
    case 0:
    break;
    };
    err = -1;
    err = test_CO_wsp_session.CreateTransaction(imethod,URL,ClientHeaders,Body,WSPTransaction);
    switch(err)
    {
    case 0:
    break;
    };

    HBufC8* buffer;
    buffer = HBufC8::NewLC(200);
    TPtr8 p = buffer->Des();
    err = -1;
    err = WSPTransaction.GetData(p, RWSPCOTrans::EResultBody);
    switch(err)
    {
    case 0:
    break;
    };

    CleanupStack::PopAndDestroy(1);// capCodec, buffer
    WSPTransaction.Release();
    test_CO_wsp_session.Close();
    handle_EPOC_WAP_Server.Close();



    What should I do now??

    Nishant

  4. #4
    Registered User
    Join Date
    Aug 2003
    Location
    Oulu, Finland
    Posts
    1,122
    Here's an article on RAS setup:

    http://www.newlc.com/article.php3?id_article=93

    In your code you're not establishing the outgoing connection. Use RGenericAgent or CIntConnectionInitiator to control how it's opened.

    > RWAPConn::TPort RemotePort = 8201;

    The port should be 9201.

    Check the EMoreData return code of GetData to see if there's more data to read.

    Lauri

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    31
    Hi Guys,

    Atlast I have been able to establish a WAP session using NULL modem cable between COM1 and COM2, Nokia WAP Browser, mrouterlite and a web server.

    My code is as follows:
    ****************************************************
    RWAPServ iWapServ;
    RWSPCOConn iWAPCOConn;
    RWSPCOTrans iWAPTransac;
    RFs aFs;
    RFile file;
    RWSPCOConn::TEvent aEvent;

    RWAPConn::TPort RemotePort = 9201;
    RWAPConn::TPort LocalPort = 0;
    TBearer Bearer = EIP;
    TBool SecureConn = EFalse;
    _LIT8(WapGateway,"*.*.*.*"); // actual IP address of WAP Gateway
    _LIT(URI,"http://*.*.*.*/index.wml"); //IP of the wml page hosted on the web server
    _LIT8(Headers, "A_Sample_WAP_Session");
    _LIT8(Body, "A_Sample_WAP_Session");
    _LIT8(ClientHeaders, "A_Sample_WAP_Session");
    TInt err = -1;
    RWAPConn::TMethod Method = RWAPConn::EGet;


    CCapCodec *iCap = CCapCodec::NewL();
    iCap->SetServerSDUSize(9000);
    iCap->SetClientSDUSize(9000);


    err = iWapServ.Connect();

    err = -1;
    err = iWAPCOConn.Open(iWapServ, WapGateway, RemotePort, LocalPort, Bearer, SecureConn);

    err = -1;
    err = iWAPCOConn.Connect(ClientHeaders, iCap);


    err = -1;
    err = iWAPCOConn.CreateTransaction(Method, URI, Headers, Body, iWAPTransac);


    err = -1;
    err = aFs.Connect();

    file.Create(aFs,_L("C:\\nishant.txt"),EFileWrite);

    RFileWriteStream aFws(file);

    HBufC8* iBuffer;
    iBuffer = HBufC8::NewL(200);
    TPtr8 p = iBuffer->Des();

    err = -1;
    err = iWAPCOConn.GetEvent(aEvent,iWAPTransac);
    do {
    err = -1;
    err = iWAPTransac.GetData(p, RWSPCOTrans::EResultBody);
    if(p.Length() > 0)
    {
    aFws.WriteL(p);
    }
    else
    break;
    }while(err == RWAPConn::EMoreData );


    aFws.CommitL();
    aFws.Close();
    file.Close();
    aFs.Close();

    iWAPTransac.Release();
    iWAPCOConn.Close();
    iWapServ.Close();

    ****************************************************

    what I am trying to do is to get some buffer data and write to a file in my filesystem.

    The problem is that the statement
    iWAPTransac.GetData(p, RWSPCOTrans::EResultBody);

    is not able to p fillup the buffer p most of the times and file remains empty, but sometimes, I get this text in my buffer: "Phone software version is not compatible" along wiht some junk chars rarely I get the contents of the actual wml page I am seeking in my file along with some junk chars.....

    could anyone explain as to why the buffer p is not being filled up properly each time......


    Thanks and regards,

    Nishant

  6. #6
    Registered User
    Join Date
    Aug 2003
    Location
    Oulu, Finland
    Posts
    1,122
    I've never actually written any GET code with the Symbian WAP server, but these look suspicious:

    > _LIT8(Headers, "A_Sample_WAP_Session");
    > _LIT8(Body, "A_Sample_WAP_Session");

    Leave them empty if you don't have anything to put in them. GET requests do not support a request body in any case.

    Also, I think you should check for system error codes after each call. User::LeaveIfError() is your friend. There seems to be some exception handling errors as well (not using the cleanup stack when you should).

    Lauri

  7. #7
    Regular Contributor
    Join Date
    Apr 2003
    Location
    Germany
    Posts
    94
    Is there no way to use the gateway simulator without setting up the RAS service?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×