epoc32/include/mw/sensoapenvelope.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description:        CSenSoapEnvelope is an utility class offering capability to 
williamr@2
    15
*                 parse XML SOAP envelope and manipulation methods to alter its
williamr@2
    16
*                 contents.
williamr@2
    17
*
williamr@2
    18
*/
williamr@2
    19
williamr@2
    20
williamr@2
    21
williamr@2
    22
williamr@2
    23
williamr@2
    24
williamr@2
    25
williamr@2
    26
williamr@2
    27
#ifndef SEN_SOAP_ENVELOPE_H
williamr@2
    28
#define SEN_SOAP_ENVELOPE_H
williamr@2
    29
williamr@2
    30
//  INCLUDES
williamr@2
    31
#include <SenBaseFragment.h>
williamr@2
    32
#include <SenSoapConstants.h>
williamr@2
    33
williamr@2
    34
// CONSTANTS
williamr@2
    35
_LIT8(KSoapActionHeaderValueEmpty,	"\"\""); // default, if not set
williamr@2
    36
williamr@2
    37
/*
williamr@2
    38
// Now declared in <SenSoapConstants.h>
williamr@2
    39
_LIT8(KSenSoap12ContentTypeHeaderValue, "application/soap+xml; charset=\"UTF-8\"");
williamr@2
    40
_LIT8(KSenSoap12AcceptHeaderValue,      "application/soap+xml");
williamr@2
    41
_LIT8(KSenSoapEnvelopeName,             "Envelope");
williamr@2
    42
_LIT8(KSenSoapEnvelopeQName,            "S:Envelope");
williamr@2
    43
williamr@2
    44
_LIT8(KSenSoapEnvelopeXmlns,            "http://schemas.xmlsoap.org/soap/envelope/");
williamr@2
    45
_LIT8(KSenSoap12EnvelopeXmlns,          "http://www.w3.org/2003/05/soap-envelope");
williamr@2
    46
_LIT8(KSenSoapEnvelopeHeaderName,       "Header");
williamr@2
    47
_LIT8(KSenSoapEnvelopeHeaderQName,      "S:Header");
williamr@2
    48
_LIT8(KSenSoapEnvelopeBodyName,         "Body");
williamr@2
    49
_LIT8(KSenSoapEnvelopeBodyQName,        "S:Body");
williamr@2
    50
_LIT8(KSenSoapFaultName,                "Fault");
williamr@2
    51
williamr@2
    52
_LIT8(KSenSoapActionHeaderName,         "SOAPAction");
williamr@2
    53
_LIT8(KSenSoapActionHeaderValueEmpty,   "\"\"");
williamr@2
    54
williamr@2
    55
williamr@2
    56
const TInt KStateParsingSoapHeader  = 20; // ignore state   (even number)
williamr@2
    57
const TInt KStateParsingSoapBody    = 40; // ignore state   (even number)
williamr@2
    58
const TInt KStateParsingSoapFault   = 5;  // save state     (odd number)
williamr@2
    59
williamr@2
    60
enum TSOAPVersion
williamr@2
    61
        {
williamr@2
    62
        ESOAP11 = 1,
williamr@2
    63
        ESOAP12
williamr@2
    64
        };
williamr@2
    65
*/
williamr@2
    66
williamr@2
    67
// FORWARD DECLARATIONS
williamr@2
    68
class CSenSoapFault;
williamr@2
    69
williamr@2
    70
// CLASS DECLARATION
williamr@2
    71
williamr@2
    72
/**
williamr@2
    73
* CSenSoapEnvelope is an utility class offering capability to parse
williamr@2
    74
* XML SOAP envelope and manipulation methods to alter its contents.
williamr@2
    75
* Typically WSC uses this class to parse messages received through
williamr@2
    76
* WSF HandleMessageL() and HandleErrorL() callbacks.
williamr@2
    77
* Class has convenience methods for checking if a SOAP envelope body
williamr@2
    78
* contains a fault and functionality to detach SOAP Fault object out
williamr@2
    79
* from it. Also possibility to set SOAPAction HTTP header is supported.
williamr@2
    80
*  @lib SenUtils.lib
williamr@2
    81
*  @since Series60 3.0
williamr@2
    82
*/
williamr@2
    83
class CSenSoapEnvelope : public CSenBaseFragment
williamr@2
    84
    {
williamr@2
    85
    public:  // Constructors and destructor
williamr@2
    86
        
williamr@2
    87
        /**
williamr@2
    88
        * Two-phased constructor.
williamr@2
    89
        */
williamr@2
    90
        IMPORT_C static CSenSoapEnvelope* NewL();
williamr@2
    91
        
williamr@2
    92
        /**
williamr@2
    93
        * Destructor.
williamr@2
    94
        */
williamr@2
    95
        IMPORT_C virtual ~CSenSoapEnvelope();
williamr@2
    96
williamr@2
    97
        // New functions
williamr@2
    98
        
williamr@2
    99
        /**
williamr@2
   100
        * Sets body of the envelope.
williamr@2
   101
        * @since Series60 3.0 
williamr@2
   102
        * @param aBody      Body (content) to be set.
williamr@2
   103
        * @return SOAP body (content) which was just set
williamr@2
   104
        */
williamr@2
   105
        IMPORT_C virtual TPtrC8 SetBodyL(const TDesC8& aBody);
williamr@2
   106
williamr@2
   107
        /**
williamr@2
   108
        * Getter for envelopes body
williamr@2
   109
        * @since Series60 3.0 
williamr@2
   110
        * @return body as CSenElement
williamr@2
   111
        */
williamr@2
   112
        IMPORT_C virtual CSenElement& BodyL();
williamr@2
   113
williamr@2
   114
        /**
williamr@2
   115
        * Getter for envelopes header
williamr@2
   116
        * @since Series60 3.0 
williamr@2
   117
        * @return header as CSenElement
williamr@2
   118
        */
williamr@2
   119
        IMPORT_C virtual CSenElement& HeaderL();
williamr@2
   120
williamr@2
   121
        /**
williamr@2
   122
        * Adds an element to the header.
williamr@2
   123
        * @since Series60 3.0 
williamr@2
   124
        * @param aHeaderElement new child element to be
williamr@2
   125
        *        added inside Header  element. Ownership
williamr@2
   126
        *        is always transferred to CSenSoapEnvelope.
williamr@2
   127
        * @return added CSenElement
williamr@2
   128
        */
williamr@2
   129
        IMPORT_C virtual CSenElement& AddHeaderL(CSenElement& aHeaderElement);
williamr@2
   130
williamr@2
   131
        /**
williamr@2
   132
        * Getter for the envelope body as a UTF-8 form XML string.
williamr@2
   133
        * @since Series60 3.0 
williamr@2
   134
        * @return body as a HBufC8 pointer. Ownership is transferred to caller.
williamr@2
   135
        */
williamr@2
   136
        IMPORT_C virtual HBufC8* BodyAsStringL();
williamr@2
   137
williamr@2
   138
        /**
williamr@2
   139
        * Checks if this SOAP envelope body contains SOAP fault or not.
williamr@2
   140
        * @since Series60 3.0 
williamr@2
   141
        * @return TBool ETrue if there is a fault, EFalse if not.
williamr@2
   142
        */
williamr@2
   143
        IMPORT_C virtual TBool IsFault();
williamr@2
   144
williamr@2
   145
        /**
williamr@2
   146
        * Detaches the <Fault> element from the envelope, removing the element
williamr@2
   147
        * from the envelope.
williamr@2
   148
        * @since Series60 3.0 
williamr@2
   149
        * @return pointer to the soap fault. Caller takes the ownership. 
williamr@2
   150
        *         NULL if <Fault> element is non-existent.
williamr@2
   151
        */
williamr@2
   152
        IMPORT_C virtual CSenSoapFault* DetachFaultL();
williamr@2
   153
        
williamr@2
   154
        /**
williamr@2
   155
        * Gets the <Fault> element. Ownership is not transferred. 
williamr@2
   156
        * NULL if not a fault.
williamr@2
   157
        * @since Series60 3.0 
williamr@2
   158
        * @return reference to SOAP fault object owned by this SOAP envelope
williamr@2
   159
        */
williamr@2
   160
        IMPORT_C virtual CSenSoapFault* FaultL();
williamr@2
   161
williamr@2
   162
        /**
williamr@2
   163
        * Sets the SOAP action HTTP header. WSF will use this value
williamr@2
   164
        * while submitting this SOAP envelope request over HTTP/S transport.
williamr@2
   165
        * @since Series60 3.0 
williamr@2
   166
        * @param aSoapAction    the SOAP Action HTTP header to be set.
williamr@2
   167
        * The default value is KSenSoapActionHeaderValueEmpty, which is
williamr@2
   168
        * two double quotation marks - "" - without any character in between.
williamr@2
   169
        * SOAP specification requires double quotation marks, even if action
williamr@2
   170
        * is empty.
williamr@2
   171
        * If a string without double quotation marks is passed, it will be 
williamr@2
   172
        * wrapped inside double quotation marks, added in the beginning and 
williamr@2
   173
        * at the end of the actual SOAP Action string.
williamr@2
   174
        *
williamr@2
   175
        * @return newly set SOAP action header. String might have been
williamr@2
   176
        * extended to include double quotation marks, if those were missing 
williamr@2
   177
        * from the argument. 
williamr@2
   178
        */
williamr@2
   179
        IMPORT_C virtual TPtrC8 SetSoapActionL(const TDesC8& aSoapAction);
williamr@2
   180
williamr@2
   181
        /**
williamr@2
   182
        * Gets the soap action header.
williamr@2
   183
        * @since Series60 3.0 
williamr@2
   184
        * @return   current SOAP action header, which is always wrapped
williamr@2
   185
        * inside double quotation marks. If SOAPAction has not been set
williamr@2
   186
        * for this SOAP envelope, function will return zero-length 
williamr@2
   187
        * descriptor (KNullDesC8)
williamr@2
   188
        */
williamr@2
   189
        IMPORT_C virtual TPtrC8 SoapAction();      
williamr@2
   190
williamr@2
   191
        /**
williamr@2
   192
        * Gets the soap action header.
williamr@2
   193
        * @since Series60 5.0 
williamr@2
   194
        * @return   current SOAP action header, which is always wrapped
williamr@2
   195
        * inside double quotation marks. If SOAPAction has not been set
williamr@2
   196
        * for this SOAP envelope, function will return zero-length 
williamr@2
   197
        * descriptor (KNullDesC8)
williamr@2
   198
        */
williamr@2
   199
			IMPORT_C TPtrC8 SoapAction2() ;
williamr@2
   200
        
williamr@2
   201
        /**
williamr@2
   202
        * Method parses given piece of XML into this SOAP envelope
williamr@2
   203
        */
williamr@2
   204
        IMPORT_C void ParseL(const TDesC8& aXml); 
williamr@2
   205
williamr@2
   206
        /*
williamr@2
   207
        * Getter for checking whether this message has at least one
williamr@2
   208
        * valid <Header> element
williamr@2
   209
        * @return ETrue, if <Header> element exists, EFalse otherwise.
williamr@2
   210
        */
williamr@2
   211
        IMPORT_C TBool HasHeader();
williamr@2
   212
williamr@2
   213
        /*
williamr@2
   214
        * Getter for checking whether this message has valid <Body> element
williamr@2
   215
        * @return ETrue, if <Body> element exists, EFalse otherwise.
williamr@2
   216
        */
williamr@2
   217
        IMPORT_C TBool HasBody();
williamr@2
   218
williamr@2
   219
        /**
williamr@2
   220
        * Getter for currently effecitve SOAP version.
williamr@2
   221
        * @return enumeration which dictates SOAP version.
williamr@2
   222
        */
williamr@2
   223
        IMPORT_C TSOAPVersion SoapVersion();
williamr@2
   224
williamr@2
   225
williamr@2
   226
    protected:  
williamr@2
   227
            
williamr@2
   228
        /**
williamr@2
   229
         *    Constructor.
williamr@2
   230
         */
williamr@2
   231
        CSenSoapEnvelope();
williamr@2
   232
        
williamr@2
   233
        /**
williamr@2
   234
        * This method should be called from the deriving
williamr@2
   235
        * classes ConstructL() methods. 
williamr@2
   236
        * @since Series60 3.0
williamr@2
   237
        */
williamr@2
   238
        IMPORT_C void BaseConstructL(TSOAPVersion aVersion);
williamr@2
   239
williamr@2
   240
        /**
williamr@2
   241
        * This method should be called from the deriving
williamr@2
   242
        * classes ConstructL() methods. 
williamr@2
   243
        * @since Series60 3.0
williamr@2
   244
        */
williamr@2
   245
        IMPORT_C void BaseConstructL();
williamr@2
   246
        
williamr@2
   247
        // New functions
williamr@2
   248
        
williamr@2
   249
        /**
williamr@2
   250
        * This method should be overridden by subclasses. 
williamr@2
   251
        * Implements functionality to parse SOAP header if one is found
williamr@2
   252
        * during parsing the envelope.
williamr@2
   253
        * Parses all elements found under top <Header> element by
williamr@2
   254
        * using DOM fragment.
williamr@2
   255
        * @since Series60 3.0 
williamr@2
   256
        * @param aNsUri            The namespace URI of the new element
williamr@2
   257
        * @param aLocalName        The local name of the new element
williamr@2
   258
        * @param aQName            The qualified name of the new element
williamr@2
   259
        * @param aAttributes    The attributes of the new element
williamr@2
   260
        */
williamr@2
   261
        IMPORT_C virtual void ParseHeaderL( const TDesC8& aNsUri,
williamr@2
   262
                                            const TDesC8& aLocalName,
williamr@2
   263
                                            const TDesC8& aQName,
williamr@2
   264
                                            const RAttributeArray& aAttributes);
williamr@2
   265
                                            
williamr@2
   266
        // Functions from base classes
williamr@2
   267
        
williamr@2
   268
        // From CSenBaseFragment 
williamr@2
   269
        
williamr@2
   270
        /**
williamr@2
   271
        * Callback function which implement the XML content handler interface.
williamr@2
   272
        * This callback will occur on each start element tag found in the XML
williamr@2
   273
        * document.
williamr@2
   274
        * The SOAP envelope recognizes and parses the following elements and
williamr@2
   275
        * their corresponding attributes inside namespace defined in 
williamr@2
   276
        * KSenSoapEnvelopeXmlns:
williamr@2
   277
        *  KSenSoapEnvelopeName,    "Envelope"
williamr@2
   278
        *  KSenSoapHeaderName,      "Header"
williamr@2
   279
        *  KSenSoapBodyName,        "Body"
williamr@2
   280
        *  KSenSoapFault,           "Fault" (only if found inside Body element)
williamr@2
   281
        *
williamr@2
   282
        * @since Series60 3.0 
williamr@2
   283
        * @param aNsUri            The namespace URI of the new element
williamr@2
   284
        * @param aLocalName        The local name of the new element
williamr@2
   285
        * @param aQName            The qualified name of the new element
williamr@2
   286
        * @param aAttributes    The attributes of the new element
williamr@2
   287
        */
williamr@2
   288
        IMPORT_C virtual void StartElementL(const TDesC8& aNsUri,
williamr@2
   289
                                            const TDesC8& aLocalName,
williamr@2
   290
                                            const TDesC8& aQName,
williamr@2
   291
                                            const RAttributeArray& aAttributes);
williamr@2
   292
williamr@2
   293
        /**
williamr@2
   294
        * Callback function which implement the XML content handler interface.
williamr@2
   295
        * This callback will occur on each end element tag found in the XML
williamr@2
   296
        * document.
williamr@2
   297
        * @since Series60 3.0 
williamr@2
   298
        * @param aNsUri        The namespace URI of the new element
williamr@2
   299
        * @param aLocalName    The local name of the new element
williamr@2
   300
        * @param aQName        The qualified name of the new element
williamr@2
   301
        */
williamr@2
   302
        IMPORT_C virtual void EndElementL(const TDesC8& aNsUri,
williamr@2
   303
                                          const TDesC8& aLocalName,
williamr@2
   304
                                          const TDesC8& aQName);
williamr@2
   305
williamr@2
   306
    protected: // Data
williamr@2
   307
        // Internal members, protected so that deriving classes have access to them.
williamr@2
   308
        CSenBaseFragment* ipBodyFragment;
williamr@2
   309
        CSenBaseFragment* ipHeaderFragment;
williamr@2
   310
        HBufC8* ipSoapAction;
williamr@2
   311
williamr@2
   312
    private: // Data
williamr@2
   313
        TBool iFault;
williamr@2
   314
       };
williamr@2
   315
williamr@2
   316
#endif // SEN_SOAP_ENVELOPE_H
williamr@2
   317
williamr@2
   318
// End of File
williamr@2
   319
williamr@2
   320
williamr@2
   321