webservices/wsframework/inc/msenremoteservicesession.h
changeset 0 62f9d29f7211
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 M_SEN_REMOTE_SERVICE_SESSION
       
    26 #define M_SEN_REMOTE_SERVICE_SESSION
       
    27 
       
    28 
       
    29 /*
       
    30  * MSenRemoteServiceSession is a non-public remote interface that is only 
       
    31  * implemented by the CSenServiceSession class. The methods of this interface 
       
    32  * are called upon by instances of CSenClientSession.
       
    33  *
       
    34  * @see RService in Java reference implementation (2005) - regardless of 
       
    35  * name-mismatch methods of this interface *equal* with RService. 
       
    36  * 
       
    37 */
       
    38 
       
    39 // INCLUDES
       
    40 #include "MSenServiceDescription.h"
       
    41 #include "msentransport.h"
       
    42 #include "MSenFragment.h"
       
    43 
       
    44 // FORWARD DECLARE
       
    45 class CSenTransportBase;
       
    46 class MSenRemoteServiceConsumer;
       
    47 class MSenRemoteHostlet;
       
    48 class CSenChunk;
       
    49 
       
    50 //enum TDescriptionClassType;
       
    51 
       
    52 
       
    53 // CLASS DECLARATION
       
    54 class MSenRemoteServiceSession  //: public MSenFragment
       
    55     {
       
    56     public:
       
    57     
       
    58         // New functions
       
    59         
       
    60         virtual MSenServiceDescription& AsServiceDescription() = 0;
       
    61         /*
       
    62          * 
       
    63          * 
       
    64          * 
       
    65          */
       
    66         virtual void WriteAsXMLToL(RWriteStream& aWriteStream) = 0;
       
    67 
       
    68     
       
    69         /*
       
    70          * StatusL() will compute and return the status code.
       
    71          *
       
    72          * @return current status of this service session. Basic
       
    73          * constants are defined in public MSenServiceConsumer.h:
       
    74          *
       
    75          * KSenConnectionStatusNew              Connection is being initialized, but not yet ready.
       
    76          * KSenConnectionStatusReady            Connection is ready to be used. For example, SubmitL()
       
    77          *                                      and SendL() methods (depending of framework) are in
       
    78          *                                      invocable state.
       
    79          * KSenConnectionStatusExpired          Connection is expired. Typically, a new connection
       
    80          *                                      needs next to be initialized in order to communicate
       
    81          *                                      with the underlying service behind this service
       
    82          *                                      connection.
       
    83          * If any error should occur in this method, it leaves.
       
    84          *  
       
    85          */
       
    86         virtual TInt StatusL() = 0;
       
    87     
       
    88         /*
       
    89          * Method synchronously submits a message to (remote) service 
       
    90          * via the transport of this session. Method will block until
       
    91          * the response is received.
       
    92          * 
       
    93          * @param aMessage is the actual request body to be sent to
       
    94          *        the remote service via the transport of this session.
       
    95          * @param aTransportProperties are the properties to be passed
       
    96          *        to the transport. Transport properties further define
       
    97          *        how the message should be carried out to the service
       
    98          *        provider. In HTTP transport's case, properties could
       
    99          *        dictate what HTTP method, header(s) and proxy params
       
   100          *        are to be used in the transport layer.
       
   101          * @param aConsumer is a reference to the actual caller of the
       
   102          *        service, which is consuming this session. Transport
       
   103          *        might be interested to resolve identifier, and other
       
   104          *        aspects of the consumer via this handle.
       
   105          * @param aResponse is reference to a pointer where transport
       
   106          *        is expected to reserve memory for tha actual response.
       
   107          * @return KErrNone if submit is successfull or otherwise some 
       
   108          *        system-wide error code.
       
   109          */
       
   110         virtual TInt SubmitL(const TDesC8& aMessage, 
       
   111                              const TDesC8& aTransportProperties,
       
   112                              MSenRemoteServiceConsumer& aConsumer,
       
   113                              HBufC8*& aResponse) = 0;
       
   114     
       
   115         /*
       
   116          * Method asynchronously sends a message to (remote) service
       
   117          * via the transport of this session. Function will typically
       
   118          * return almost immediately, since the service response will
       
   119          * be received via spesific callback methods.
       
   120          * 
       
   121          * @param aMessage is the actual request body to be sent to
       
   122          *        the remote service via the transport of this session.
       
   123          * @param aTransportProperties are the properties to be passed
       
   124          *        to the transport. Transport properties further define
       
   125          *        how the message should be carried out to the service
       
   126          *        provider. In HTTP transport's case, properties could
       
   127          *        dictate what HTTP method, header(s) and proxy params
       
   128          *        are to be used in the transport layer.
       
   129          * @param aConsumer is a reference to the actual caller of the
       
   130          *        service, which is consuming this session. Transport
       
   131          *        might be interested to resolve identifier, and other
       
   132          *        aspects of the consumer via this handle.
       
   133          * @param aTxnId is reference to transaction id,
       
   134          *        to be set by the transport to identify
       
   135          *        this request.
       
   136          * @param aRevalidationError contains error / SOAP Fault from
       
   137          *        authentication service (like WS-* STS or Liberty AS / IDP)
       
   138          * @return KErrNone if send is successfull or otherwise some 
       
   139          *        system-wide error code.
       
   140          */
       
   141         virtual TInt SendL( const TDesC8& aMessage, 
       
   142                             const TDesC8& aTransportProperties,
       
   143                             MSenRemoteServiceConsumer& aConsumer,
       
   144                             TInt& aTxnId,
       
   145                             HBufC8*& aRevalidationError ) = 0;
       
   146     
       
   147         /*
       
   148          * Method synchronously submits a message to (remote) service 
       
   149          * via the transport of this session.
       
   150          * 
       
   151          * @param aSoapMessage is the actual request body - a SOAP
       
   152          *        envelope, which is to be sent to remote service 
       
   153          *        via the transport of this session.
       
   154          * @param aTransportProperties are the properties to be passed
       
   155          *        to the transport. Transport properties further define
       
   156          *        how the message should be carried out to the service
       
   157          *        provider. In HTTP transport's case, properties could
       
   158          *        dictate what HTTP method, header(s) and proxy params
       
   159          *        are to be used in the transport layer.
       
   160          * @param aConsumer is a reference to the actual caller of the
       
   161          *        service, which is consuming this session. Transport
       
   162          *        might be interested to resolve identifier, and other
       
   163          *        aspects of the consumer via this handle.
       
   164          * @param aResponse is reference to a pointer where transport
       
   165          *        is expected to reserve memory for tha actual response.
       
   166          * @return KErrNone if submit is successfull or otherwise some 
       
   167          *        system-wide error code.
       
   168          */
       
   169         virtual TInt SubmitSoapL(const TDesC8& aSoapMessage,
       
   170                                  const TDesC8& aTransportProperties,
       
   171                                  MSenRemoteServiceConsumer& aConsumer,
       
   172                                  HBufC8*& aResponse) = 0;
       
   173         /*
       
   174          * Method asynchronously sends a message to (remote) service
       
   175          * via the transport of this session. Function will typically
       
   176          * return almost immediately, since the service response will
       
   177          * be received via spesific callback methods.
       
   178          * 
       
   179          * @param aSoapMessage is the actual request body - a SOAP
       
   180          *        envelope, which is to be sent to remote service 
       
   181          *        via the transport of this session.
       
   182          * @param aTransportProperties are the properties to be passed
       
   183          *        to the transport. Transport properties further define
       
   184          *        how the message should be carried out to the service
       
   185          *        provider. In HTTP transport's case, properties could
       
   186          *        dictate what HTTP method, header(s) and proxy params
       
   187          *        are to be used in the transport layer.
       
   188          * @param aConsumer is a reference to the actual caller of the
       
   189          *        service, which is consuming this session. Transport
       
   190          *        might be interested to resolve identifier, and other
       
   191          *        aspects of the consumer via this handle.
       
   192          * @param aTxnId is reference to transaction id,
       
   193          *        to be set by the transport to identify
       
   194          *        this request.
       
   195          * @param aRevalidationError contains error / SOAP Fault from
       
   196          *        authentication service (like WS-* STS or Liberty AS / IDP)
       
   197          * @return KErrNone if send is successfull or otherwise some 
       
   198          *        system-wide error code.
       
   199          */
       
   200         virtual TInt SendSoapL( const TDesC8& aSoapMessage,
       
   201                                 const TDesC8& aTransportProperties,
       
   202                                 MSenRemoteServiceConsumer& aConsumer,
       
   203                                 TInt& aTxnId,
       
   204                                 HBufC8*& aRevalidationError ) = 0;
       
   205     
       
   206     
       
   207         /**
       
   208         * Method checks if this session is ready to interact with (remote)
       
   209         * service. Typically, if service invocation framework requires 
       
   210         * credentials, they are checked inside this method.
       
   211 <        * @return boolean indicating if this session is ready (ETrue) or
       
   212         *         not (EFalse) to interact with (possibly remote) service.
       
   213         */
       
   214         virtual TBool IsReadyL() = 0;
       
   215 
       
   216         virtual TInt HasFacetL(const TDesC8& aURI, TBool& aHasFacet) = 0;
       
   217         virtual TInt FacetValue(TDesC8& aURI, HBufC8*& aValueTo) = 0;
       
   218         virtual TInt CompleteServerMessagesOnOffL(const TBool& aCompleteOnOff) = 0;
       
   219         virtual TPtrC8 Endpoint() = 0;
       
   220         virtual TPtrC8 Contract() = 0;
       
   221         virtual TPtrC8 FrameworkId() = 0;
       
   222         virtual void StartTransaction() = 0;
       
   223         virtual void TransactionCompleted() = 0;
       
   224         virtual MSenServiceDescription::TDescriptionClassType DescriptionClassType() = 0;
       
   225 
       
   226         /**
       
   227         * Method is used to apply transport properties for this service session.
       
   228         * In basic implementation, the properties information is passed to 
       
   229         * transport of this session.
       
   230         * @param aProperties contains transport properties properties as descriptor
       
   231         * @param aConsumer is the "actor", typically the remote consumer which is 
       
   232         *        invoking this method.
       
   233         * @return KErrNone if successful, or otherwise some system-wide error code
       
   234         */
       
   235         virtual TInt SetTransportPropertiesL(const TDesC8& aProperties,
       
   236                                              MSenRemoteServiceConsumer& aConsumer) = 0;
       
   237 
       
   238         virtual TInt TransportPropertiesL(HBufC8*& aProperties,
       
   239                                              MSenRemoteServiceConsumer& aConsumer) = 0;
       
   240 
       
   241 
       
   242 
       
   243         /**
       
   244         * Sets the transport plug-in instance,
       
   245         * passing the ownership to this 
       
   246         * session.
       
   247         * @param aTransport is the new transport for this session.
       
   248         * Note that if a Transport instance is already owned, it 
       
   249         * will be deleted.
       
   250         */
       
   251         virtual void SetTransportL(CSenTransportBase* aTransport) = 0;
       
   252 
       
   253         /**
       
   254         * Getter for currently effective transport instance.
       
   255         * It is strongly recommended, that service sessions
       
   256         * themselves acquire transport via TransportL -variant,
       
   257         * which is capable of factoring a transport in case
       
   258         * that it does not exist already.
       
   259         * @return currently set transport, or NULL
       
   260         * 
       
   261         */
       
   262         virtual MSenTransport* Transport() const = 0;
       
   263 
       
   264         /**
       
   265         * Returns the transport of this session. If transport is not
       
   266         * yet known (owned), an attempt to create a transport for this
       
   267         * session will be performed, and this attempt may result this
       
   268         * method to leave.
       
   269         * @param aRequestor is the consumer of this session, which is
       
   270         * about to utilize the transport of this session.
       
   271         * Leaves with system-wide error code in case that a new transport
       
   272         * cannot be instantiated.
       
   273         */
       
   274         virtual MSenTransport& TransportL(MSenRemoteServiceConsumer& aRequestor) = 0;
       
   275 
       
   276         /**
       
   277         * Sets the hostlet for this session. HostletConnection server-side
       
   278         * sessions (CSenClientSessions) call this method in order to provide
       
   279         * their own reference to session, which can be utilized by HostletTransport
       
   280         * plug-ins, so that the messages from remote service consumers can be routed.
       
   281         * @param aHostlet is a reference to MSenRemoteHostlet implementation, typically
       
   282         * to CSenClientSession class. Note that it is perfectly legal to pass
       
   283         * NULL as aHostlet - that call just means, that any existing MSenRemoteHostlet
       
   284         * will be "unset" / detached from this session.
       
   285         * @return KErrNone if successful, or otherwise some system-wide error code.
       
   286         * Method may leave, if aHostlet is found invalid.
       
   287         */
       
   288         virtual TInt SetHostletL(MSenRemoteHostlet* aHostlet) = 0;
       
   289 
       
   290  
       
   291         virtual MSenRemoteHostlet* Hostlet() const = 0;        
       
   292 
       
   293         /**
       
   294         * Removes a service consumer from this session.
       
   295         *
       
   296         * Removed consumer will no longer receive any callbacks
       
   297         * from the service provider it used to communicate with.
       
   298         * Typically, MSenRemoteServiceConsumer implementations call
       
   299         * this method from their destructors. When the count of
       
   300         * session consumers is decreased to zero, and session
       
   301         * does not hold any reference to a MSenRemoteHostlet either
       
   302         * the default implementation provided in here will also
       
   303         * delete the associated transport plug-in instance, in order
       
   304         * to save (memory, messaging stack etc) resources .
       
   305         * @param aConsumer is the service consumer to be removed.
       
   306         * @return positive index of successfully removed consumer or
       
   307         *         KErrNotFound - if consumer was not found
       
   308         */
       
   309         virtual TInt RemoveConsumerL(MSenRemoteServiceConsumer& aConsumer) = 0;
       
   310         
       
   311         /**
       
   312         * This method is invoked by WS-stack Core on each call to
       
   313         * CSenHostletConnection::RespondL. The typical implementation
       
   314         * in service session class will use associated transport plug-in
       
   315         * to complete the pending transaction. If contents of the message
       
   316         * do not require any modification, then the session can rely that
       
   317         * the response set by the hostlet application (MSenHostlet) is
       
   318         * already in place. If there is need to modify the response in
       
   319         * SIF spesific way, then the message can be resolved using the
       
   320         * txn ID (before completing this transaction).
       
   321         * @param aProvider is the interface to the hostlet that is providing
       
   322         * this response -- via RespondL issued inside (or after) 
       
   323         * MSenHostlet::ServiceL.
       
   324         * @param aTxnId is the transaction ID of this request/response pair
       
   325         * @param aServiceCode is the code that was set to MSenHostletResponse
       
   326         * by the hostlet application
       
   327         * @param aRecipientsConsumerId may be used to resolve interested
       
   328         * service consumer, which issued the request to the hostlet
       
   329         * @param aMessageChunk contains the message as raw 8-bit data,
       
   330         * plus it's other properties
       
   331         * @return TInt KErrNone on success, or otherwise some of the system-wide
       
   332         * error codes.
       
   333         */
       
   334         virtual TInt ProvideHostletResponseL(MSenRemoteHostlet& aProvider,
       
   335                                              const TInt aTxnId,
       
   336                                              const TInt aServiceCode,
       
   337                                              const TDesC8& aRecipientsConsumerId,
       
   338                                              CSenChunk& aMessageChunk) = 0;
       
   339         
       
   340 
       
   341         //virtual HBufC8* AsXmlL() = 0;
       
   342 
       
   343         //virtual TInt SignMessages(const TDesC8& aAlgoritm,
       
   344         //                          const TDesC8& aSigningKey) = 0;
       
   345     };
       
   346 #endif // M_SEN_REMOTE_SERVICE_SESSION
       
   347 
       
   348