Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    118

    WebPost not working on device, working fine on emulator

    Hi All,
    I am sending a post to webserver using default connection, code works fine on
    emulator, but it doesnt work on device not even return error code, it remains in waiting state.

    Please help on this as it is urgent.
    Here is the code :


    void CPostHelper::IssueHTTPPostL(const TDesC8& aUri,
    const TDesC8& aContentType, const TDesC8& aBody, TBool ShowDialog)
    {
    if (IsActive())
    {
    Cancel();
    }

    delete iUri;
    iUri = NULL;
    delete iContentType;
    iContentType = NULL;
    delete iBody;
    iBody = NULL;

    iUri = aUri.AllocL();
    iContentType = aContentType.AllocL();
    iBody = aBody.AllocL();

    // Create HTTP connection
    TRAPD(err, SetupConnectionL());
    DoHTTPPostL();
    iXmlHandler = CXmlHandler::NewL();
    //Only Show dialog when not showing browser
    ShowWaitDialog = ShowDialog;
    if(ShowWaitDialog)
    {
    waitDialog = new ( ELeave ) CAknWaitDialog( NULL, ETrue );
    // Show the wait Dialog
    waitDialog->ExecuteLD( R_AKNEXNOTE_WAIT_NOTE_SOFTKEY_CANCEL );
    ShowWaitDialog = EFalse;
    itimer1 = ConnectionTimer::NewL();
    itimer1->StartL(KConnectionTimeOut);
    }

    }


    void CPostHelper::SetupConnectionL()
    {
    if (iConnectionSetupDone)
    {
    //User::Leave(KErrAlreadyExists);
    return;
    }
    if (IsActive())
    {
    User::Leave(KErrInUse);
    }

    iSession.OpenL();

    InstallAuthenticationL(iSession);
    CCommsDatabase* commDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
    CleanupStack::PushL(commDB);

    // initialize a view
    CCommsDbConnectionPrefTableView* commDBView =
    commDB->OpenConnectionPrefTableInRankOrderLC(
    ECommDbConnectionDirectionOutgoing);

    // go to the first record
    User::LeaveIfError(commDBView->GotoFirstRecord());

    // Declare a prefTableView Object.
    CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;

    // read the connection preferences
    commDBView->ReadConnectionPreferenceL(pref);
    TUint32 iIapID = pref.iBearer.iIapId;

    // pop and destroy the IAP View
    CleanupStack::PopAndDestroy(commDBView);

    // pop and destroy the database object
    CleanupStack::PopAndDestroy(commDB);
    //iFirstTime = EFalse;

    ////////////////////////////
    TBool connected(EFalse);
    TCommDbConnPref prefs;
    //prefs.SetIapId(userSelection.iId);
    //prefs.SetIapId(2);//Set Uncategorised
    //prefs.SetIapId(iSelectedIap);


    prefs.SetIapId(iIapID);
    prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
    prefs.SetDirection(ECommDbConnectionDirectionOutgoing);
    prefs.SetBearerSet(ECommDbBearerGPRS);
    User::LeaveIfError(iSocketServ.Connect());
    User::LeaveIfError(iConnection.Open(iSocketServ));

    iConnection.Start(prefs, iStatus);
    iConnectionSetupDone = ETrue;
    connected = ETrue;
    SetActive();
    }

    void CPostHelper:oHTTPPostL()
    {
    // Parse string to URI
    TUriParser8 uri;
    uri.Parse(*iUri);

    // Copy data to be posted into member variable; iPostData is used later in
    // methods inherited from MHTTPDataSupplier.
    delete iPostData;
    iPostData = 0;
    iPostData = iBody->AllocL();

    // Set the session's connection info...

    RStringPool strPool = iSession.StringPool();
    RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();

    // ...to use the socket server
    connInfo.SetPropertyL(strPool.StringF(HTTP::EHttpSocketServ,
    RHTTPSession::GetTable()), THTTPHdrVal(iSocketServ.Handle()));


    // Get request method string for HTTP POST
    //RStringF method = iSession.StringPool().StringF(HTTP::EPOST,RHTTPSession::GetTable());
    RStringF method = iSession.StringPool().StringF(HTTP::EPOST,
    RHTTPSession::GetTable());

    // Open transaction with previous method and parsed uri. This class will
    // receive transaction events in MHFRunL and MHFRunError.
    iTransaction = iSession.OpenTransactionL(uri, *this, method);
    iTransactionOpen = ETrue;

    //->
    // Set headers for request; user agent, accepted content type and body's
    // content type.
    RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();
    SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
    SetHeaderL(hdr, HTTP::EAccept, KAccept);
    SetHeaderL(hdr, HTTP::EContentType, KContentTypeForm);

    // Set this class as an data supplier. Inherited MHTTPDataSupplier methods
    // are called when framework needs to send body data.
    MHTTPDataSupplier* dataSupplier = this;
    iTransaction.Request().SetBody(*dataSupplier);

    // Submit the transaction. After this the framework will give transaction
    // events via MHFRunL and MHFRunError.
    iTransaction.SubmitL();
    }

  2. #2
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    118

    Re: WebPost not working on device, working fine on emulator

    Any update on this??
    I have used NetworkServices capability, is there any other capability is required for this ?

  3. #3
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    118

    Re: WebPost not working on device, working fine on emulator

    Anyone worked on post please reply to this

Similar Threads

  1. Replies: 1
    Last Post: 2009-10-25, 18:07
  2. Emulator is not woring fine!
    By ASP-NewBie in forum Symbian
    Replies: 20
    Last Post: 2008-05-27, 12:18
  3. SMS deletion (working in emulator not on device)
    By Puneet_Sharma in forum Symbian Networking & Messaging (Closed)
    Replies: 9
    Last Post: 2008-04-03, 16:01
  4. Bluetooth Security: What exactly is an untrusted device?
    By rahulmcs in forum Bluetooth Technology
    Replies: 1
    Last Post: 2005-12-02, 07:26

Posting Permissions

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