Hello,
I've been trying to get c++ to open a connection to an asp file and retrieve data from my server for about two weeks now...
All i want to do is get the data and save it exactly as it is returned into a text file.
I have the text saving code (grey) working fine, but i cant get the http connection to work.
I'm writing this in carbide.c++ Express edition.

Can anyone help me with my code? am I missing something?

Thanks
Paul

this is my cpp file:
Code:
// INCLUDE FILES
#include <eikmenup.h>
#include <avkon.hrh>
#include <aknnotewrappers.h>
#include <stringloader.h>
#include <http.h>
#include <WriteII.rsg>
#include <eikenv.h>
#include <f32file.h>
#include <s32file.h>
#include <e32base.h>
#include <uri8.h>
#include <chttpformencoder.h>
#include <HttpStringConstants.h>
#include <http\RHTTPSession.h>
#include <http\RHTTPTransaction.h>
#include <http\mhttptransactioncallback.h>
#include <http\rhttpheaders.h>

#include "WriteII.pan"
#include "WriteIIAppUi.h"
#include "WriteIIAppView.h"
#include "WriteII.hrh"

_LIT( KMyFile, "C:\\data\\WriteII.txt" );
_LIT( KText, "data for file in WriteII");
_LIT8( KWebAdd, "http://www.myserver.co.uk/script.asp");
_LIT8( KUserAgent, "myserver 1.1M");

// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// CWriteIIAppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//

void CWriteIIAppUi::ConstructL()
    {
    // Initialise app UI with standard value.
    
    BaseConstructL();
    iSession.OpenL();
    TBuf8<50> temp8;
    temp8.Copy(_L8("http://www.myserver.co.uk//script.asp"));
    TBufC8<50> tempC8(temp8);
    TUriParser8 uri;
	uri.Parse(temp8);
   	RStringF method = iSession.StringPool().StringF(HTTP::EGET, RHTTPSession::GetTable());
	trans = iSession.OpenTransactionL(tempC8, *iTransObs, method);
    trans.SubmitL();
    
    
    RFs fsSession;
    fsSession.Connect();
    RFile myFile;
    myFile.Create(fsSession,KMyFile,EFileShareAny | EFileWrite);  
    myFile.Open(fsSession,KMyFile,EFileShareAny|EFileWrite);
    TPtrC8 representation((TUint8*)(&KText)->Ptr(), (&KText)->Size());
    //_LIT8(KWriteBuf,"hello test 2");
    myFile.Write(representation);
    fsSession.Close();
    iSession.Close();
Exit();
	}
// -----------------------------------------------------------------------------
// CWriteIIAppUi::CWriteIIAppUi()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CWriteIIAppUi::CWriteIIAppUi()
    {
    // No implementation required
    }

// CWriteIIAppUi::~CWriteIIAppUi()
// Destructor.
CWriteIIAppUi::~CWriteIIAppUi()
    {
    if ( iAppView )
        {
        delete iAppView;
        iAppView = NULL;
        }

    }
// CWriteIIAppUi::HandleCommandL()
// Takes care of command handling.
void CWriteIIAppUi::HandleCommandL( TInt aCommand )
    {
    switch( aCommand )
        {
        case EEikCmdExit:
        case EAknSoftkeyExit:
            Exit();
            break;

        case ECommand1:
            {
            
            // Load a string from the resource file and display it
            HBufC* textResource = StringLoader::LoadLC( R_COMMAND1_TEXT );
            CAknInformationNote* informationNote;

            informationNote = new ( ELeave ) CAknInformationNote;

            // Show the information Note with
            // textResource loaded with StringLoader.
            informationNote->ExecuteLD( *textResource);

            // Pop HBuf from CleanUpStack and Destroy it.
            CleanupStack::PopAndDestroy( textResource );
            }
            break;
		case ECommand2:
			{
			
			RFs fsSession;
			RFile rFile;
			
			// Connects a client process to the fileserver
			User::LeaveIfError(fsSession.Connect());
			CleanupClosePushL(fsSession);
			
			//Open file where the stream text is
			User::LeaveIfError(rFile.Open(fsSession,KMyFile, EFileStreamText));//EFileShareReadersOnly));// EFileStreamText));
			CleanupClosePushL(rFile);
			
			// copy stream from file to RFileStream object
			RFileReadStream inputFileStream(rFile);
    		CleanupClosePushL(inputFileStream);
    		
    		// HBufC descriptor is created from the RFileStream object.
    		HBufC* fileData = HBufC::NewLC(inputFileStream, 32);

            CAknInformationNote* informationNote;

            informationNote = new ( ELeave ) CAknInformationNote;
            // Show the information Note
            informationNote->ExecuteLD( *fileData);			
			
			// Pop loaded resources from the cleanup stack
			CleanupStack::PopAndDestroy(4); // filedata, inputFileStream, rFile, fsSession
			fsSession.Close();
			}
			break;
        default:
            Panic( EWriteIIUi );
            break;
        }
    }
// -----------------------------------------------------------------------------
//  Called by the framework when the application status pane
//  size is changed.  Passes the new client rectangle to the
//  AppView
// -----------------------------------------------------------------------------
//
void CWriteIIAppUi::HandleStatusPaneSizeChange()
{
	iAppView->SetRect( ClientRect() );
	
} 

// End of File
This is my .h file:
Code:
#ifndef __WRITEIIAPPUI_h__
#define __WRITEIIAPPUI_h__

// INCLUDES
#include <aknappui.h>
#include <coecntrl.h>
#include <http.h>
#include <uri8.h>
#include <f32file.h>
#include <http\mhttptransactioncallback.h>
#include <http\RHTTPTransaction.h>
#include <http\rhttpsession.h>



// FORWARD DECLARATIONS
class CWriteIIAppView;
class MHTTPTransactionCallBack;
class TUriParser8;
class TUriC8;
class RHTTPTransaction;
class RHTTPSession;


// CLASS DECLARATION
/**
* CWriteIIAppUi application UI class.
* Interacts with the user through the UI and request message processing
* from the handler class
*/
class CWriteIIAppUi : public CBase,
					  public CAknAppUi//,
					 // public MHTTPTransactionCallback
					 
    {
    public: // Constructors and destructor

        /**
        * ConstructL.
        * 2nd phase constructor.
        */
       
        void ConstructL();
        void IssueHTTPGetL(const TUriC8& uri);
       
        /**
        * CWriteIIAppUi.
        * C++ default constructor. This needs to be public due to
        * the way the framework constructs the AppUi
        */
        CWriteIIAppUi();

        /**
        * ~CWriteIIAppUi.
        * Virtual Destructor.
        */
        virtual ~CWriteIIAppUi();

    private:  // Functions from base classes

        /**
        * From CEikAppUi, HandleCommandL.
        * Takes care of command handling.
        * @param aCommand Command to be handled.
        */
        void HandleCommandL( TInt aCommand );
        

        /**
        *  HandleStatusPaneSizeChange.
        *  Called by the framework when the application status pane
 		*  size is changed.
        */

		void HandleStatusPaneSizeChange();
	private: // Data
		RHTTPSession iSession;
		RHTTPTransaction trans;
		MHTTPTransactionCallBack* iTransObs;
		TBuf8<50> aUri;
		//TBuf<50> uri;
	
        /**
        * The application view
        * Owned by CWriteIIAppUi
        */
        CWriteIIAppView* iAppView;
   
    };

#endif // __WRITEIIAPPUI_h__

// End of File