webservices/wshttpchanneltransportplugin/src/senhttpchanneltransportplugin.cpp
changeset 28 0802db42e4e9
parent 2 150a13bad6af
child 29 5743aa3a72c3
equal deleted inserted replaced
2:150a13bad6af 28:0802db42e4e9
    24 
    24 
    25 
    25 
    26 
    26 
    27 
    27 
    28 // INCLUDE FILES
    28 // INCLUDE FILES
    29 #include "senserviceconnection.h"
    29 #include "SenServiceConnection.h"
    30 #include "senhttpchanneltransportplugin.h"
    30 #include "senhttpchanneltransportplugin.h"
    31 #include "senhttpchannelimpl.h"
    31 #include "senhttpchannelimpl.h"
    32 #include "senhttpsyncrequester.h"
    32 #include "senhttpsyncrequester.h"
    33 #include "senxmlutils.h"
    33 #include "SenXmlUtils.h"
    34 #include "senidentityprovider.h"
    34 #include "SenIdentityProvider.h"
    35 #include "senwspattern.h"
    35 #include "senwspattern.h"
    36 #include "senfragment.h"
    36 #include "SenFragment.h"
    37 #include "senelement.h"
    37 #include "SenElement.h"
    38 #include "sendebug.h"
    38 #include "sendebug.h"
    39 #include "msenproperty.h"
    39 #include "MSenProperty.h"
    40 #include "senhttptransportproperties.h" // Utils\inc
    40 #include "SenHttpTransportProperties.h" // Utils\inc
    41 #include "sentransportcontext.h"
    41 #include "sentransportcontext.h"
    42 #include "senlayeredhttptransportproperties.h" // internal Framework\inc
    42 #include "senlayeredhttptransportproperties.h" // internal Framework\inc
    43 #include "msenmessagecontext.h"
    43 #include "msenmessagecontext.h"
    44 #include "msenmessage.h"
    44 #include "MSenMessage.h"
    45 #include "sensoapmessage2.h"
    45 #include "SenSoapMessage2.h"
    46 #include "rsendocument.h"
    46 #include "RSenDocument.h"
    47 #include "senparser.h"
    47 #include "SenParser.h"
    48 #include "senservicesession.h"
    48 #include "senservicesession.h"
    49 #include "senlogger.h"
    49 #include "senlogger.h"
    50 #include "senclientsession.h"
    50 #include "senclientsession.h"
    51 #include <xmlengchunkcontainer.h>
    51 #include <xml/dom/xmlengchunkcontainer.h>
    52 #include <xmlengfilecontainer.h>
    52 #include <xml/dom/xmlengfilecontainer.h>
    53 #include <xmlengserializer.h>
    53 #include <xml/dom/xmlengserializer.h>
    54 
    54 
    55 
    55 
    56 
    56 
    57 namespace
    57 namespace
    58     {
    58     {
   102     iRequester(NULL),
   102     iRequester(NULL),
   103     iHttpChannel(NULL),
   103     iHttpChannel(NULL),
   104     iProperties(NULL),
   104     iProperties(NULL),
   105     iConsumerMap(EFalse, ETrue), 
   105     iConsumerMap(EFalse, ETrue), 
   106     iSessionMap(EFalse, EFalse), // iConsumerMap deletes the txnIds (using same "new reserved" TInt here!)
   106     iSessionMap(EFalse, EFalse), // iConsumerMap deletes the txnIds (using same "new reserved" TInt here!)
   107     iStatusCode(0)
   107     iStatusCode(0),
       
   108     iIsConnectionFailed(EFalse)
   108     {
   109     {
   109     }
   110     }
   110 
   111 
   111 CSenHttpChannelTransportPlugin::~CSenHttpChannelTransportPlugin()
   112 CSenHttpChannelTransportPlugin::~CSenHttpChannelTransportPlugin()
   112     {
   113     {
   113     TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::~CSenHttpChannelTransportPlugin()");
   114     TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::~CSenHttpChannelTransportPlugin()");
   114     iConsumerMap.Reset(); // deletes the txnIds!
   115     iConsumerMap.Reset(); // deletes the txnIds!
   115     iSessionMap.Reset(); 
   116     iSessionMap.Reset(); 
   116 
   117 
   117     delete iHttpChannel;
   118     delete iHttpChannel;
       
   119     iHttpChannel = NULL;
   118     delete iRequester;
   120     delete iRequester;
       
   121     iRequester = NULL;
   119     delete iProperties;
   122     delete iProperties;
       
   123     iProperties = NULL;
   120 
   124 
   121     delete ipCtx;
   125     delete ipCtx;
   122     ipCtx = NULL;
   126     ipCtx = NULL;
       
   127 
       
   128     // Close the log file and the connection to the server.
       
   129     TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("SenHttpChannel - Log file closed.")));
       
   130     TLSLOG_CLOSE(KSenHttpChannelLogChannelBase);
   123 
   131 
   124     TLSLOG(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,(_L("Got last data chunk.")));
   132     TLSLOG(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,(_L("Got last data chunk.")));
   125     TLSLOG_CLOSE(KSenHttpChannelObserverLogChannelBase);
   133     TLSLOG_CLOSE(KSenHttpChannelObserverLogChannelBase);
   126     }
   134     }
   127 
   135 
   129     {
   137     {
   130     TLSLOG_OPEN(KSenHttpChannelObserverLogChannelBase,KSenHttpChannelObserverLogLevel,KSenHttpChannelObserverLogDir,KSenHttpChannelObserverLogFile	);
   138     TLSLOG_OPEN(KSenHttpChannelObserverLogChannelBase,KSenHttpChannelObserverLogLevel,KSenHttpChannelObserverLogDir,KSenHttpChannelObserverLogFile	);
   131     // Open connection to the file logger server
   139     // Open connection to the file logger server
   132     TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::ConstructL(): log file opened.");
   140     TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::ConstructL(): log file opened.");
   133     TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::ConstructL - Version 2 [2006-05-09]");
   141     TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::ConstructL - Version 2 [2006-05-09]");
       
   142 
       
   143     // Open connection to the file logger server
       
   144     TLSLOG_OPEN(KSenHttpChannelLogChannelBase, KSenHttpChannelLogLevel, KSenHttpChannelLogDir, KSenHttpChannelLogFile);
       
   145     TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("SenHttpChannel - Log file opened")));
   134 
   146 
   135     if( ipCtx )
   147     if( ipCtx )
   136         {
   148         {
   137         // Attempt to find pre-defined IAP ID from transport context
   149         // Attempt to find pre-defined IAP ID from transport context
   138         CSenWSDescription& initializer = ipCtx->GetInitializerL();
   150         CSenWSDescription& initializer = ipCtx->GetInitializerL();
   450     }
   462     }
   451 
   463 
   452 // Method to catch async error responses from httpchannel
   464 // Method to catch async error responses from httpchannel
   453 void CSenHttpChannelTransportPlugin::ResponseErrorL(TInt aRequestId, TInt aErrorCode, HBufC8* apErrorBody,CSenHttpTransportProperties* aHttpProperties)
   465 void CSenHttpChannelTransportPlugin::ResponseErrorL(TInt aRequestId, TInt aErrorCode, HBufC8* apErrorBody,CSenHttpTransportProperties* aHttpProperties)
   454     {
   466     {
       
   467     TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KMinLogLevel, _L8("CSenHttpChannelTransportPlugin::ResponseErrorL() - aErrorCode [%d]"), aErrorCode));
   455     CleanupStack::PushL(apErrorBody);
   468     CleanupStack::PushL(apErrorBody);
   456     iHttpChannel->DisableTimeOutL(aRequestId);
   469     if( (aErrorCode < KErrNone) && (apErrorBody == NULL) || aErrorCode == KErrAbort)
       
   470     	{
       
   471     	TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::ResponseErrorL() Set iIsConnectionFailed True");
       
   472     	iHttpChannel->ResetIapId();
       
   473     	iHttpChannel->ResetUsedIapId();
       
   474     	iHttpChannel->SetExplicitIapDefined(EFalse);
       
   475     	iIsConnectionFailed = ETrue;
       
   476     	TUint32 zeroIap = 0;
       
   477 			TBuf8<128> buf;
       
   478 	    buf.AppendFormat(_L8("%u"), zeroIap);
       
   479     	LayeredPropertiesL().SetPropertyL(KIapIdLocalName, buf); //Reset the layered properties in case of wrong IAP
       
   480     	}
       
   481     else
       
   482     	{
       
   483     	iHttpChannel->SetExplicitIapDefined(ETrue);
       
   484     	}	
       
   485     if(iHttpChannel)
       
   486     	{
       
   487     	iHttpChannel->DisableTimeOutL(aRequestId);
       
   488     	}
   457 #ifdef _SENDEBUG    
   489 #ifdef _SENDEBUG    
   458     TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::ResponseErrorL:");
       
   459     TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KNormalLogLevel, _L8("- Request's txnID: %d"), aRequestId));
   490     TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KNormalLogLevel, _L8("- Request's txnID: %d"), aRequestId));
   460     if ( apErrorBody )
   491     if ( apErrorBody )
   461         {
   492         {
   462         TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KMaxLogLevel, _L8("- apErrorBody:")));
   493         TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KMaxLogLevel, _L8("- apErrorBody:")));
   463         TLSLOG_ALL(KSenHttpChannelObserverLogChannelBase,KMaxLogLevel,(*apErrorBody));
   494         TLSLOG_ALL(KSenHttpChannelObserverLogChannelBase,KMaxLogLevel,(*apErrorBody));
   553     TInt retVal(KErrNone);
   584     TInt retVal(KErrNone);
   554 
   585 
   555     // ALWAYS HANDLE IAP ID FIRST, SINCE IT *CAN RESET* HTTPCHANNEL!
   586     // ALWAYS HANDLE IAP ID FIRST, SINCE IT *CAN RESET* HTTPCHANNEL!
   556     
   587     
   557     TUint32 iapId(KErrNone);
   588     TUint32 iapId(KErrNone);
   558 
       
   559     retVal = LayeredPropertiesL().IapIdL(iapId);
   589     retVal = LayeredPropertiesL().IapIdL(iapId);
   560     if(retVal==KErrNone)
   590     TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KMinLogLevel, _L8("- CSenHttpChannelTransportPlugin::ApplyPropertiesL() - iapId [%d]"), iapId));
   561         {
   591 	TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KMinLogLevel, _L8("- LayeredPropertiesL() retVal [%d]"), retVal)); 
   562         TInt resetPerformed = ResetHttpChannelByIapIdL(iapId);
   592     if(iIsConnectionFailed)
       
   593         {
       
   594 		TInt resetPerformed = ResetHttpChannelByIapIdL(0); //Incase of connection error set Iap ID 0
   563 #ifdef _SENDEBUG
   595 #ifdef _SENDEBUG
   564         if(resetPerformed == KErrNone)
   596         if(resetPerformed == KErrNone)
   565             {
   597             {
   566             TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KNormalLogLevel, _L8("- IAP re-set performed: (%d)"), iapId));
   598             TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KNormalLogLevel, _L8("- IAP re-set performed: (%d)"), iapId));
   567             }
   599             }
   568 #endif // _SENDEBUG
   600 #endif // _SENDEBUG
       
   601         }
       
   602     else if(retVal==KErrNone)
       
   603         {
       
   604        	TInt resetPerformed = ResetHttpChannelByIapIdL(iapId);
       
   605 #ifdef _SENDEBUG
       
   606         if(resetPerformed == KErrNone)
       
   607             {
       
   608             TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KNormalLogLevel, _L8("- IAP re-set performed: (%d)"), 0));
       
   609             }
       
   610 #endif // _SENDEBUG				
   569         }
   611         }
   570 
   612 
   571     // Handle ProxyHost and ProxyPort
   613     // Handle ProxyHost and ProxyPort
   572     TPtrC8 proxyHost;
   614     TPtrC8 proxyHost;
   573     retVal = LayeredPropertiesL().ProxyHostL(proxyHost);
   615     retVal = LayeredPropertiesL().ProxyHostL(proxyHost);
   606     return KErrNone; 
   648     return KErrNone; 
   607     }
   649     }
   608 
   650 
   609 TInt CSenHttpChannelTransportPlugin::ResetHttpChannelByIapIdL(TUint32 aIapId)
   651 TInt CSenHttpChannelTransportPlugin::ResetHttpChannelByIapIdL(TUint32 aIapId)
   610     {
   652     {
       
   653     TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::ResetHttpChannelByIapIdL()");
   611     TUint32 effectiveIapId(KErrNone);
   654     TUint32 effectiveIapId(KErrNone);
   612     TBool explicitIapIdDefined(EFalse);
   655     TBool explicitIapIdDefined(EFalse);
   613     if(iHttpChannel)
   656     if(iHttpChannel)
   614         {
   657         {
   615         explicitIapIdDefined = iHttpChannel->EffectiveIapId(effectiveIapId);
   658         explicitIapIdDefined = iHttpChannel->EffectiveIapId(effectiveIapId);
   616         }
   659         }
   617 
   660 
   618     TInt retVal(KErrNone);
   661     TInt retVal(KErrNone);
   619     if(!explicitIapIdDefined || explicitIapIdDefined && effectiveIapId != aIapId)
   662     TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KMinLogLevel, _L8("- explicitIapIdDefined[%d], effectiveIapId[%d], aIapId[%d]"), explicitIapIdDefined, effectiveIapId, aIapId));
       
   663     if(!explicitIapIdDefined || (explicitIapIdDefined && (effectiveIapId != aIapId) ) || iIsConnectionFailed)
   620         {
   664         {
   621         TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::ResetHttpChannel():");
   665         TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::ResetHttpChannel():");
   622 
   666         iIsConnectionFailed = EFalse;
   623         delete iHttpChannel;
   667         delete iHttpChannel;
   624         iHttpChannel = NULL;
   668         iHttpChannel = NULL;
   625         delete iRequester;
   669         delete iRequester;
   626         iRequester = NULL;
   670         iRequester = NULL;
   627         TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KNormalLogLevel, _L8("- New IAP ID: %d"), aIapId));
   671         TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KMinLogLevel, _L8("- New IAP ID: %d"), aIapId));
   628         CSenHttpChannel* pHttpChannel = CSenHttpChannelImpl::NewL(iServiceManager, aIapId);
   672         CSenHttpChannel* pHttpChannel = CSenHttpChannelImpl::NewL(iServiceManager, aIapId);
   629         
   673         
   630         CleanupStack::PushL(pHttpChannel);
   674         CleanupStack::PushL(pHttpChannel);
   631 
   675 
   632         CSenHttpSyncRequester* pRequester = CSenHttpSyncRequester::NewL(pHttpChannel, this);
   676         CSenHttpSyncRequester* pRequester = CSenHttpSyncRequester::NewL(pHttpChannel, this);
   638         }
   682         }
   639     else
   683     else
   640         {
   684         {
   641         retVal = KErrAlreadyExists;
   685         retVal = KErrAlreadyExists;
   642         }
   686         }
       
   687     TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KMinLogLevel, _L8("CSenHttpChannelTransportPlugin::ResetHttpChannelByIapIdL() - returns [%d]"), retVal));
   643     return retVal;
   688     return retVal;
   644     }
   689     }
   645 
   690 
   646 TInt CSenHttpChannelTransportPlugin::CompleteTransaction(const TInt aTxnId,
   691 TInt CSenHttpChannelTransportPlugin::CompleteTransaction(const TInt aTxnId,
   647                                                          const TInt /* aCompletionCode */)
   692                                                          const TInt /* aCompletionCode */)