webservices/wsframework/inc/senwebservicesession.h
changeset 0 62f9d29f7211
child 29 5743aa3a72c3
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Header declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 #ifndef SEN_WEB_SERVICE_SESSION_H
       
    26 #define SEN_WEB_SERVICE_SESSION_H
       
    27 
       
    28 //  INCLUDES
       
    29 #include "senservicesession.h"
       
    30 #include "seninternalcredential.h"
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class MSenServiceConsumer;
       
    34 class MServiceDescription;
       
    35 class CSenCredential;
       
    36 class CSenSoapMessage;
       
    37 
       
    38 // CLASS DECLARATION
       
    39 class CSenWebServiceSession : public CSenServiceSession,
       
    40                               public MSenCredentialObserver
       
    41     {
       
    42     public: // Destructor
       
    43         IMPORT_C virtual ~CSenWebServiceSession();
       
    44 
       
    45         // New functions
       
    46         IMPORT_C virtual TInt InitializeFromL(MSenServiceDescription& aServiceDescription);
       
    47 
       
    48         /**
       
    49         * Computes the status of this session (checks the credentials).
       
    50         * @return the status code, one of the following:
       
    51         * 
       
    52         */
       
    53         IMPORT_C virtual TInt ComputeStatusL();
       
    54 
       
    55         /*
       
    56         * Computes the status of this session and returns the status.
       
    57         * @return ETrue, if this session is expired and has invalid credentials
       
    58         *         EFalse, if this session is is ready and has valid credentials
       
    59         */
       
    60         IMPORT_C virtual TBool IsExpiredL(); // Remove, not called from anywhere
       
    61 
       
    62         IMPORT_C virtual TInt AddCredentialL(CSenCredential& aCredential);
       
    63         IMPORT_C virtual TInt ConstructSecurityTokenL(CSenCredential& aCredential,
       
    64                                                       HBufC8*& aToken);
       
    65 
       
    66         IMPORT_C virtual TInt NewMessageL(CSenSoapMessage*& aMessage);
       
    67         IMPORT_C virtual TInt MessageForSendingL(const TDesC8& aBody,
       
    68                                                  const TDesC8& aSenderID,
       
    69                                                  CSenSoapMessage*& aMessage);
       
    70 
       
    71         IMPORT_C virtual TInt ParseResponseL(const TDesC8& aResponse,
       
    72                                              HBufC8*& aParsed);
       
    73 
       
    74 
       
    75         IMPORT_C virtual CSenXmlReader* XmlReader();
       
    76         IMPORT_C virtual TInt ParseResponseL(const TDesC8& aResponse,
       
    77                                          CSenSoapMessage*& aMessage);
       
    78 
       
    79         IMPORT_C virtual TInt ParseMessageL(CSenSoapMessage& aSOAPMessage);
       
    80 
       
    81         /**
       
    82         * Adds a consumer. Takes ownership!
       
    83         * @return KErrNone if no errors, otherwise some system-wide errorcode
       
    84         */
       
    85         IMPORT_C virtual TInt AddConsumerL(MSenRemoteServiceConsumer& aConsumer);
       
    86         IMPORT_C virtual MSenRemoteServiceConsumer* Consumer();
       
    87 
       
    88         /**
       
    89         * Return an array in which the consumers (clients) of this ServiceSession
       
    90         * reside. This method is called from within several other methods of the
       
    91         * abstract ServiceSession class.
       
    92         * This method should be implemented by a subclass
       
    93         * specific to a ServiceInvocationFramework implementation.
       
    94         * @param    aConsumers  List of the current consumers. Owned by
       
    95         *           ServiceSession.
       
    96         * Ownership of the aConsumers is NOT transfered to the caller
       
    97         * @return TInt - a KErrNone or error
       
    98         */
       
    99         IMPORT_C virtual TInt Consumers(RServiceConsumerArray& aConsumers) const;
       
   100 
       
   101         IMPORT_C virtual TInt SubmitL(const TDesC8& aMessage,
       
   102                                       const TDesC8& aTransportProperties,
       
   103                                       MSenRemoteServiceConsumer& aConsumer,
       
   104                                       HBufC8*& aResponse);
       
   105 
       
   106         IMPORT_C virtual TInt SendL( const TDesC8& aMessage, 
       
   107                                      const TDesC8& aTransportProperties,
       
   108                                      MSenRemoteServiceConsumer& aConsumer,
       
   109                                      TInt& aTxnId,
       
   110                                      HBufC8*& aRevalidationError );
       
   111 
       
   112 
       
   113         IMPORT_C virtual TInt SubmitSoapL(const TDesC8& aSoapMessage, 
       
   114                                           const TDesC8& aTransportProperties,
       
   115                                           MSenRemoteServiceConsumer& aConsumer,
       
   116                                           HBufC8*& aResponse);
       
   117 
       
   118         IMPORT_C virtual TInt SendSoapL( const TDesC8& aSoapMessage, 
       
   119                                          const TDesC8& aTransportProperties,
       
   120                                          MSenRemoteServiceConsumer& aConsumer,
       
   121                                          TInt& aTxnId,
       
   122                                          HBufC8*& aRevalidationError );
       
   123 
       
   124         /**
       
   125         * Method checks if this session is ready to interact with (remote)
       
   126         * service. Typically, if service invocation framework requires 
       
   127         * credentials, they are checked inside this method.
       
   128         * @return boolean indicating if this session is ready (ETrue) or
       
   129         *         not (EFalse) to interact with (possibly remote) service.
       
   130         */
       
   131         IMPORT_C virtual TBool IsReadyL();
       
   132 
       
   133         // SOAP processing callback functions:
       
   134         IMPORT_C virtual TInt SendSoapMessageToConsumerL( CSenSoapMessage* apMessage,
       
   135                                                           const TInt aTxnId,
       
   136                                                           MSenRemoteServiceConsumer& aConsumer,
       
   137                                                           MSenProperties* aResponseTransportProperties );
       
   138 
       
   139         /**
       
   140         * This synchronous method (pair for SubmitL) checks if the service 
       
   141         * invocation framework (this session) can handle this fault, and 
       
   142         * if not, then an attempt is made to delivered this fault to session
       
   143         * consumer.
       
   144         *
       
   145         * @param aSoapMessage is the SOAP message representing fault.
       
   146         * @param aResponse is where either SOAP fault OR - if some
       
   147         * framework (like ID-WSF) was able to handle this fault (recover)
       
   148         *        - the valid response from the service, achieved
       
   149         *        by re-submitted request (for example to new endpoint,
       
   150         *        if the handled fault was "endpoint moved" -type fault.
       
   151         * @param aResponseTransportProperties will contain the properties of
       
   152         * handled error (either for fault OR valid response -transaction)
       
   153         *        
       
   154         * 
       
   155         * @return KErrSenSoapFault, if this error (fault) could not be handled.
       
   156         *         In this case, aResponse contains (extracted) SOAP fault
       
   157         *         element.
       
   158         *         KErrNone, if recovery was possible and successful, and
       
   159         *                   then aResponse contains valid response from 
       
   160         *                   the service. The SOAP fault, which was taken
       
   161         *                   care here - between (remote) service and
       
   162         *                   framework - remains thus "hidden" from actual 
       
   163         *                   web service consumer.
       
   164         *         KErrSenSoapFault, if fault could not be handled. Now
       
   165         *                   aResponse will contain the extracted SOAP
       
   166         *                   fault element as UTF-8 descriptor (TDesC8)
       
   167         *         KErrSenInternal, the SOAP fault could not be found from
       
   168         *                   aSoapMessage.
       
   169         *         KErrNotFound - the consumer could not be found.
       
   170         */
       
   171         IMPORT_C virtual TInt HandleSoapFaultL(CSenSoapMessage* apSoapMessage,
       
   172                                                HBufC8*& aResponse /*,
       
   173                                                CSenTransportProperties*& aResponseTransportProperties */);
       
   174        
       
   175         /**
       
   176         * This asynchronous method (pair for SendL) checks if the service 
       
   177         * invocation framework (this session) can handle this fault, and 
       
   178         * if not, then an attempt is made to delivered this fault to 
       
   179         * session consumer.
       
   180         *
       
   181         * @param aSoapMessage is the SOAP message representing fault.
       
   182         * @param aErrorCode, is the error code received from transport
       
   183         * @param aTxnId is the transaaction id from transport, which 
       
   184         *        can be used to map this error response to consumer's 
       
   185         *        request.
       
   186         * @param aConsumer is the consumer which was calling the transport
       
   187         *        and originally sent the request.
       
   188         * @param aResponseTransportProperties includes response properties
       
   189         * for the handled error
       
   190         * @return KErrNone, if error was either succesfully handled or
       
   191         *         processed (delivered to consumer) The SOAP fault, which 
       
   192         *         was taken care between (remote) service and ID-WSF framework
       
   193         *         is hereby "hidden" from actual web service consumer.
       
   194         */
       
   195         IMPORT_C virtual TInt HandleSoapFaultL(CSenSoapMessage* apSoapMessage,
       
   196                                            const TInt aErrorCode,
       
   197                                            const TInt aTxnID,
       
   198                                            MSenRemoteServiceConsumer& aConsumer,
       
   199                                            MSenProperties* aResponseTransportProperties);
       
   200 
       
   201 
       
   202         // From MSenServiceSession:
       
   203         IMPORT_C TInt SendToConsumerL(HBufC8* aMessage,
       
   204                                       const TInt aTxnId,
       
   205                                       MSenRemoteServiceConsumer& aConsumer,
       
   206                                       MSenProperties* aResponseTransportProperties = NULL); 
       
   207 
       
   208         IMPORT_C TInt SendErrorToConsumerL(const TInt aErrorCode,
       
   209                                            HBufC8* apError,
       
   210                                            const TInt aTxnId,
       
   211                                            MSenRemoteServiceConsumer& aConsumer,
       
   212                                            MSenProperties* aResponseTransportProperties = NULL); 
       
   213 
       
   214         IMPORT_C TInt HandleErrorL(const TInt aErrorCode,
       
   215                                    HBufC8* apError,
       
   216                                    const TInt aTxnId,
       
   217                                    MSenRemoteServiceConsumer& aConsumer,
       
   218                                    MSenProperties* aResponseTransportProperties = NULL); 
       
   219 
       
   220         IMPORT_C virtual TInt SendToHostletL(MSenRemoteHostlet& aReceiver,
       
   221                                              const TDesC8& aMessage,
       
   222                                              const TInt aTxnId,
       
   223                                              MSenRemoteServiceConsumer& aFrom,
       
   224                                              MSenProperties* aProperties);
       
   225 
       
   226         IMPORT_C virtual TInt ProvideHostletResponseL( MSenRemoteHostlet& aProvider,
       
   227                                                        const TInt aTxnId,
       
   228                                                        const TInt aServiceCode,
       
   229                                                        const TDesC8& aRecipientsConsumerId,
       
   230                                                        CSenChunk& aMessageChunk );
       
   231 
       
   232         IMPORT_C virtual void SetFrameworkHeadersL(CSenSoapMessage& aMsg);
       
   233         IMPORT_C virtual TInt SetUserNameL(TDesC8& aUsername);
       
   234 
       
   235         IMPORT_C virtual TPtrC8 Endpoint();
       
   236         IMPORT_C virtual TPtrC8 Contract();
       
   237         IMPORT_C virtual TPtrC8 FrameworkId();
       
   238         IMPORT_C virtual TPtrC8 FrameworkVersion();
       
   239         IMPORT_C virtual const TTime& ValidUntilL();
       
   240         IMPORT_C virtual void SetContractL(const TDesC8& aContract);
       
   241         IMPORT_C virtual void SetEndPointL(const TDesC8& aURI);
       
   242         IMPORT_C virtual void SetSecurityL(const TDesC8& aSecurity);
       
   243         IMPORT_C virtual void SetCredentialPtrL(RSenCredentialPtr aCredentialPtr);	//codescannerwarnings
       
   244         IMPORT_C virtual void FillCredentialIdentifierL(CSenCredentialIdentifier& aIdentifier);
       
   245         IMPORT_C virtual void StartTransaction();
       
   246         IMPORT_C virtual void TransactionCompleted();
       
   247         IMPORT_C virtual void WriteAsXMLToL(RWriteStream& aWriteStream);
       
   248         IMPORT_C virtual TTimeIntervalMicroSeconds ClientServerInterval();
       
   249         IMPORT_C virtual void SetClientServerIntervalL(TTimeIntervalMicroSeconds aInterval);	//codescannerwarnings
       
   250         IMPORT_C TBool HasConsumer() const;
       
   251 
       
   252         
       
   253         // From CSenWSDescription:
       
   254         IMPORT_C virtual TBool HasSuperClass( TDescriptionClassType aType );
       
   255         IMPORT_C virtual TInt SetTransportCueL(const TDesC8& aCue);
       
   256         IMPORT_C virtual TPtrC8 TransportCue();
       
   257 
       
   258         IMPORT_C TInt TryToSearchValidCredentialL();	//codescannerwarnings
       
   259         
       
   260         IMPORT_C virtual void CredentialChanged(TSenCredentialChange aChange, TAny* aPointer);
       
   261         
       
   262         // from MSenRemoteServiceSession
       
   263 //        IMPORT_C TInt RemoveConsumerL(MSenRemoteServiceConsumer& aConsumer);
       
   264 
       
   265         IMPORT_C TInt GetCredentialIdL();
       
   266         
       
   267         IMPORT_C TInt AddCredentialObserverL(CSenInternalCredential& aCredential);
       
   268 
       
   269     protected:
       
   270         
       
   271         /**
       
   272         * C++ default constructor.
       
   273         */
       
   274         IMPORT_C CSenWebServiceSession( TDescriptionClassType aType,
       
   275                                         MSIF& aFramework);
       
   276         
       
   277         /**
       
   278         * By default Symbian 2nd phase constructor is private.
       
   279         */                              
       
   280         IMPORT_C void ConstructL();
       
   281     
       
   282         IMPORT_C HBufC8* SecurityL();
       
   283         
       
   284         IMPORT_C TBool HasSecurity();
       
   285         
       
   286         void SetCredentialIdL(TInt aCredentialId);	//codescannerwarnings
       
   287         
       
   288     private:
       
   289         TInt HandleBodyWithoutParsingL(CSenSoapMessage& aMessage, const TDesC8& aResponse);
       
   290     
       
   291     protected: // Data
       
   292         TTimeIntervalMicroSeconds iClientServerInterval;
       
   293 
       
   294          // Data, which also subclasses can access
       
   295         TTime iValidUntil;
       
   296         
       
   297         RSenCredentialPtr  iCredentialPtr;
       
   298         HBufC8* iTransportCue; 
       
   299 
       
   300     private: // Data
       
   301         HBufC8* iEndpoint;
       
   302         HBufC8* iContract;
       
   303         HBufC8* iFrameworkId;
       
   304        
       
   305 
       
   306         // credentials as xml
       
   307         HBufC8* iSecurity;
       
   308     };
       
   309 
       
   310 #endif // SEN_WEB_SERVICE_SESSION_H
       
   311 
       
   312 // End of File