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@2
|
5 |
* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@2
|
7 |
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.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_ENVELOPE2_H
|
williamr@2
|
28 |
#define SEN_SOAP_ENVELOPE2_H
|
williamr@2
|
29 |
|
williamr@2
|
30 |
// INCLUDES
|
williamr@2
|
31 |
#include <SenDomFragmentBase.h>
|
williamr@2
|
32 |
#include <SenSoapConstants.h>
|
williamr@2
|
33 |
#include <MSenMessage.h>
|
williamr@2
|
34 |
|
williamr@2
|
35 |
// CONSTANTS
|
williamr@2
|
36 |
/*
|
williamr@2
|
37 |
// Now declared in <SenSoapConstants.h>
|
williamr@2
|
38 |
_LIT8(KSenSoapEnvelopeName, "Envelope");
|
williamr@2
|
39 |
_LIT8(KSenSoapEnvelopePrefix, "S");
|
williamr@2
|
40 |
_LIT8(KSenSoapEnvelopeXmlns, "http://schemas.xmlsoap.org/soap/envelope/");
|
williamr@2
|
41 |
_LIT8(KSenSoap12EnvelopeXmlns, "http://www.w3.org/2003/05/soap-envelope");
|
williamr@2
|
42 |
_LIT8(KSenSoapEnvelopeHeaderName, "Header");
|
williamr@2
|
43 |
_LIT8(KSenSoapEnvelopeHeaderQName, "S:Header");
|
williamr@2
|
44 |
_LIT8(KSenSoapEnvelopeBodyName, "Body");
|
williamr@2
|
45 |
_LIT8(KSenSoapEnvelopeBodyQName, "S:Body");
|
williamr@2
|
46 |
_LIT8(KSenSoapFaultName, "Fault");
|
williamr@2
|
47 |
|
williamr@2
|
48 |
_LIT8(KSenSoapActionHeaderName, "SOAPAction");
|
williamr@2
|
49 |
_LIT8(KSenSoapActionHeaderValueEmpty, "\"\"");
|
williamr@2
|
50 |
|
williamr@2
|
51 |
const TInt KStateParsingSoapHeader = 20; // ignore state (even number)
|
williamr@2
|
52 |
const TInt KStateParsingSoapBody = 40; // ignore state (even number)
|
williamr@2
|
53 |
const TInt KStateParsingSoapFault = 5; // save state (odd number)
|
williamr@2
|
54 |
|
williamr@2
|
55 |
enum TSOAPVersion
|
williamr@2
|
56 |
{
|
williamr@2
|
57 |
ESOAP11 = 1,
|
williamr@2
|
58 |
ESOAP12
|
williamr@2
|
59 |
};
|
williamr@2
|
60 |
*/
|
williamr@2
|
61 |
|
williamr@2
|
62 |
// FORWARD DECLARATIONS
|
williamr@2
|
63 |
class CSenSoapFault2;
|
williamr@2
|
64 |
class CSenTransportProperties;
|
williamr@2
|
65 |
class CSenMessageContext;
|
williamr@2
|
66 |
class MSenMessageContext;
|
williamr@2
|
67 |
|
williamr@2
|
68 |
// CLASS DECLARATION
|
williamr@2
|
69 |
|
williamr@2
|
70 |
/**
|
williamr@2
|
71 |
* CSenSoapEnvelope is an utility class offering capability to parse
|
williamr@2
|
72 |
* XML SOAP envelope and manipulation methods to alter its contents.
|
williamr@2
|
73 |
* Typically WSC uses this class to parse messages received through
|
williamr@2
|
74 |
* WSF HandleMessageL() and HandleErrorL() callbacks.
|
williamr@2
|
75 |
* Class has convenience methods for checking if a SOAP envelope body
|
williamr@2
|
76 |
* contains a fault and functionality to detach SOAP Fault object out
|
williamr@2
|
77 |
* from it. Also possibility to set SOAPAction HTTP header is supported.
|
williamr@2
|
78 |
* @lib SenUtils.lib
|
williamr@2
|
79 |
* @since Series60 4.0
|
williamr@2
|
80 |
*/
|
williamr@2
|
81 |
class CSenSoapEnvelope2 : public CSenFragmentBase, public MSenMessage
|
williamr@2
|
82 |
{
|
williamr@2
|
83 |
public: // Constructors and destructor
|
williamr@2
|
84 |
|
williamr@2
|
85 |
/**
|
williamr@2
|
86 |
* Two-phased constructor.
|
williamr@2
|
87 |
*/
|
williamr@2
|
88 |
IMPORT_C static CSenSoapEnvelope2* NewL();
|
williamr@2
|
89 |
|
williamr@2
|
90 |
/**
|
williamr@2
|
91 |
* Two-phased constructor.
|
williamr@2
|
92 |
*/
|
williamr@2
|
93 |
IMPORT_C static CSenSoapEnvelope2* NewLC();
|
williamr@2
|
94 |
|
williamr@2
|
95 |
/**
|
williamr@2
|
96 |
* Two-phased constructor.
|
williamr@2
|
97 |
*/
|
williamr@2
|
98 |
IMPORT_C static CSenSoapEnvelope2* NewL(MSenMessageContext& aContext);
|
williamr@2
|
99 |
|
williamr@2
|
100 |
/**
|
williamr@2
|
101 |
* Two-phased constructor.
|
williamr@2
|
102 |
*/
|
williamr@2
|
103 |
IMPORT_C static CSenSoapEnvelope2* NewLC(MSenMessageContext& aContext);
|
williamr@2
|
104 |
|
williamr@2
|
105 |
/**
|
williamr@2
|
106 |
* Two-phased copy constructor.
|
williamr@2
|
107 |
*/
|
williamr@2
|
108 |
IMPORT_C static CSenSoapEnvelope2* NewL(CSenSoapEnvelope2& aEnvelope);
|
williamr@2
|
109 |
|
williamr@2
|
110 |
/**
|
williamr@2
|
111 |
* Two-phased copy constructor.
|
williamr@2
|
112 |
*/
|
williamr@2
|
113 |
IMPORT_C static CSenSoapEnvelope2* NewLC(CSenSoapEnvelope2& aEnvelope);
|
williamr@2
|
114 |
|
williamr@2
|
115 |
/**
|
williamr@2
|
116 |
* Destructor.
|
williamr@2
|
117 |
*/
|
williamr@2
|
118 |
IMPORT_C virtual ~CSenSoapEnvelope2();
|
williamr@2
|
119 |
|
williamr@2
|
120 |
// New functions
|
williamr@2
|
121 |
|
williamr@2
|
122 |
/**
|
williamr@2
|
123 |
* Sets body of the envelope.
|
williamr@2
|
124 |
* @since Series60 4.0
|
williamr@2
|
125 |
* @param aBody Body (content) to be set.
|
williamr@2
|
126 |
* @return SOAP body (content) which was just set
|
williamr@2
|
127 |
*/
|
williamr@2
|
128 |
IMPORT_C virtual TPtrC8 SetBodyL(const TDesC8& aBody);
|
williamr@2
|
129 |
|
williamr@2
|
130 |
/**
|
williamr@2
|
131 |
* Sets body of the envelope.
|
williamr@2
|
132 |
* @since Series60 4.0
|
williamr@2
|
133 |
* @param aBody Body (content) to be set.
|
williamr@2
|
134 |
* @return SOAP body (content) which was just set
|
williamr@2
|
135 |
*/
|
williamr@2
|
136 |
IMPORT_C virtual TXmlEngElement SetBodyL(TXmlEngElement aBodyElement);
|
williamr@2
|
137 |
|
williamr@2
|
138 |
/**
|
williamr@2
|
139 |
* Getter for envelopes body
|
williamr@2
|
140 |
* @since Series60 4.0
|
williamr@2
|
141 |
* @return body as TXmlEngElement
|
williamr@2
|
142 |
*/
|
williamr@2
|
143 |
IMPORT_C virtual TXmlEngElement BodyL();
|
williamr@2
|
144 |
|
williamr@2
|
145 |
/**
|
williamr@2
|
146 |
* Getter for envelopes header
|
williamr@2
|
147 |
* @since Series60 4.0
|
williamr@2
|
148 |
* @return header as TXmlEngElement
|
williamr@2
|
149 |
*/
|
williamr@2
|
150 |
IMPORT_C virtual TXmlEngElement HeaderL();
|
williamr@2
|
151 |
|
williamr@2
|
152 |
/**
|
williamr@2
|
153 |
* Adds an element to the header.
|
williamr@2
|
154 |
* @since Series60 4.0
|
williamr@2
|
155 |
* @param aHeaderElement new child element to be
|
williamr@2
|
156 |
* added inside Header element. Ownership
|
williamr@2
|
157 |
* is always transferred to CSenSoapEnvelope.
|
williamr@2
|
158 |
* @return added TXmlEngElement
|
williamr@2
|
159 |
*/
|
williamr@2
|
160 |
IMPORT_C virtual TXmlEngElement AddHeaderL(TXmlEngElement aHeaderElement);
|
williamr@2
|
161 |
|
williamr@2
|
162 |
/**
|
williamr@2
|
163 |
* Getter for the envelope body as a UTF-8 form XML string.
|
williamr@2
|
164 |
* @since Series60 4.0
|
williamr@2
|
165 |
* @return body as a HBufC8 pointer. Ownership is transferred to caller.
|
williamr@2
|
166 |
*/
|
williamr@2
|
167 |
IMPORT_C virtual HBufC8* BodyAsStringL();
|
williamr@2
|
168 |
|
williamr@2
|
169 |
/**
|
williamr@2
|
170 |
* Checks if this SOAP envelope body contains SOAP fault or not.
|
williamr@2
|
171 |
* @since Series60 4.0
|
williamr@2
|
172 |
* @return TBool ETrue if there is a fault, EFalse if not.
|
williamr@2
|
173 |
*/
|
williamr@2
|
174 |
IMPORT_C virtual TBool IsFault();
|
williamr@2
|
175 |
|
williamr@2
|
176 |
/**
|
williamr@2
|
177 |
* Detaches the <Fault> element from the envelope, removing the element
|
williamr@2
|
178 |
* from the envelope.
|
williamr@2
|
179 |
* @since Series60 4.0
|
williamr@2
|
180 |
* @return pointer to the soap fault. Caller takes the ownership.
|
williamr@2
|
181 |
* NULL if <Fault> element is non-existent.
|
williamr@2
|
182 |
*/
|
williamr@2
|
183 |
IMPORT_C virtual CSenSoapFault2* DetachFaultL();
|
williamr@2
|
184 |
|
williamr@2
|
185 |
/**
|
williamr@2
|
186 |
* Gets the <Fault> element. Ownership is not transferred.
|
williamr@2
|
187 |
* NULL if not a fault.
|
williamr@2
|
188 |
* @since Series60 4.0
|
williamr@2
|
189 |
* @return reference to SOAP fault object owned by this SOAP envelope
|
williamr@2
|
190 |
*/
|
williamr@2
|
191 |
IMPORT_C virtual CSenSoapFault2* FaultL();
|
williamr@2
|
192 |
|
williamr@2
|
193 |
/**
|
williamr@2
|
194 |
* Sets the SOAP action HTTP header. WSF will use this value
|
williamr@2
|
195 |
* while submitting this SOAP envelope request over HTTP/S transport.
|
williamr@2
|
196 |
* @since Series60 4.0
|
williamr@2
|
197 |
* @param aSoapAction the SOAP Action HTTP header to be set.
|
williamr@2
|
198 |
* The default value is KSenSoapActionHeaderValueEmpty, which is
|
williamr@2
|
199 |
* two double quotation marks - "" - without any character in between.
|
williamr@2
|
200 |
* SOAP specification requires double quotation marks, even if action
|
williamr@2
|
201 |
* is empty.
|
williamr@2
|
202 |
* If a string without double quotation marks is passed, it will be
|
williamr@2
|
203 |
* wrapped inside double quotation marks, added in the beginning and
|
williamr@2
|
204 |
* at the end of the actual SOAP Action string.
|
williamr@2
|
205 |
*
|
williamr@2
|
206 |
* @return newly set SOAP action header. String might have been
|
williamr@2
|
207 |
* extended to include double quotation marks, if those were missing
|
williamr@2
|
208 |
* from the argument.
|
williamr@2
|
209 |
*/
|
williamr@2
|
210 |
IMPORT_C virtual TPtrC8 SetSoapActionL(const TDesC8& aSoapAction);
|
williamr@2
|
211 |
|
williamr@2
|
212 |
/**
|
williamr@2
|
213 |
* Gets the soap action header.
|
williamr@2
|
214 |
* @since Series60 4.0
|
williamr@2
|
215 |
* @return current SOAP action header, which is always wrapped
|
williamr@2
|
216 |
* inside double quotation marks. If SOAPAction has not been set
|
williamr@2
|
217 |
* to this SOAP envelope instance, function will return zero-length
|
williamr@2
|
218 |
* descriptor (KNullDesC8)
|
williamr@2
|
219 |
*/
|
williamr@2
|
220 |
IMPORT_C virtual TPtrC8 SoapAction();
|
williamr@2
|
221 |
|
williamr@2
|
222 |
/*
|
williamr@2
|
223 |
* Getter for checking whether this message has at least one
|
williamr@2
|
224 |
* valid <Header> element
|
williamr@2
|
225 |
* @return ETrue, if <Header> element exists, EFalse otherwise.
|
williamr@2
|
226 |
*/
|
williamr@2
|
227 |
IMPORT_C TBool HasHeader();
|
williamr@2
|
228 |
|
williamr@2
|
229 |
/*
|
williamr@2
|
230 |
* Getter for checking whether this message has valid <Body> element
|
williamr@2
|
231 |
* @return ETrue, if <Body> element exists, EFalse otherwise.
|
williamr@2
|
232 |
*/
|
williamr@2
|
233 |
IMPORT_C TBool HasBody();
|
williamr@2
|
234 |
|
williamr@2
|
235 |
/**
|
williamr@2
|
236 |
* Getter for currently effecitve SOAP version.
|
williamr@2
|
237 |
* @return enumeration which dictates SOAP version.
|
williamr@2
|
238 |
*/
|
williamr@2
|
239 |
IMPORT_C virtual TSOAPVersion SoapVersion();
|
williamr@2
|
240 |
|
williamr@2
|
241 |
public: // From MSenMessage
|
williamr@2
|
242 |
IMPORT_C virtual TClass Type();
|
williamr@2
|
243 |
IMPORT_C virtual TDirection Direction();
|
williamr@2
|
244 |
IMPORT_C virtual TInt SetContext(MSenMessageContext* apOwnedContext);
|
williamr@2
|
245 |
IMPORT_C virtual MSenMessageContext* Context();
|
williamr@2
|
246 |
IMPORT_C virtual TInt SetProperties(MSenProperties* apOwnedProperties);
|
williamr@2
|
247 |
IMPORT_C virtual MSenProperties* Properties();
|
williamr@2
|
248 |
|
williamr@2
|
249 |
IMPORT_C virtual TBool IsSafeToCast(TClass aType);
|
williamr@2
|
250 |
IMPORT_C virtual TInt TxnId();
|
williamr@2
|
251 |
IMPORT_C virtual MSenMessage* CloneL();
|
williamr@2
|
252 |
|
williamr@2
|
253 |
protected:
|
williamr@2
|
254 |
|
williamr@2
|
255 |
/**
|
williamr@2
|
256 |
* Constructor.
|
williamr@2
|
257 |
*/
|
williamr@2
|
258 |
CSenSoapEnvelope2();
|
williamr@2
|
259 |
/**
|
williamr@2
|
260 |
* This method should be called from the deriving
|
williamr@2
|
261 |
* classes ConstructL() methods.
|
williamr@2
|
262 |
* @since Series60 4.0
|
williamr@2
|
263 |
*/
|
williamr@2
|
264 |
IMPORT_C void BaseConstructL(TSOAPVersion aVersion);
|
williamr@2
|
265 |
|
williamr@2
|
266 |
/**
|
williamr@2
|
267 |
* This method should be called from the deriving
|
williamr@2
|
268 |
* classes ConstructL() methods.
|
williamr@2
|
269 |
* @since Series60 4.0
|
williamr@2
|
270 |
*/
|
williamr@2
|
271 |
IMPORT_C void BaseConstructL();
|
williamr@2
|
272 |
|
williamr@2
|
273 |
/**
|
williamr@2
|
274 |
* This method should be called from the deriving
|
williamr@2
|
275 |
* classes ConstructL() methods.
|
williamr@2
|
276 |
* @since Series60 4.0
|
williamr@2
|
277 |
*/
|
williamr@2
|
278 |
IMPORT_C void BaseConstructL(MSenMessageContext& aMessage);
|
williamr@2
|
279 |
|
williamr@2
|
280 |
/**
|
williamr@2
|
281 |
* This method should be called from the deriving
|
williamr@2
|
282 |
* classes ConstructL() methods.
|
williamr@2
|
283 |
* @since Series60 4.0
|
williamr@2
|
284 |
*/
|
williamr@2
|
285 |
IMPORT_C void BaseConstructL(MSenMessageContext& aMessage,
|
williamr@2
|
286 |
TSOAPVersion aVersion);
|
williamr@2
|
287 |
|
williamr@2
|
288 |
/**
|
williamr@2
|
289 |
* This method should be called from the deriving
|
williamr@2
|
290 |
* classes ConstructL() methods.
|
williamr@2
|
291 |
* @since Series60 4.0
|
williamr@2
|
292 |
*/
|
williamr@2
|
293 |
IMPORT_C void BaseConstructL(CSenSoapEnvelope2& aEnvelope);
|
williamr@2
|
294 |
|
williamr@2
|
295 |
// New functions
|
williamr@2
|
296 |
|
williamr@2
|
297 |
/**
|
williamr@2
|
298 |
* This method should be overridden by subclasses.
|
williamr@2
|
299 |
* Implements functionality to parse SOAP header if one is found
|
williamr@2
|
300 |
* during parsing the envelope.
|
williamr@2
|
301 |
* Parses all elements found under top <Header> element by
|
williamr@2
|
302 |
* using DOM fragment.
|
williamr@2
|
303 |
* @since Series60 4.0
|
williamr@2
|
304 |
* @param aNsUri The namespace URI of the new element
|
williamr@2
|
305 |
* @param aLocalName The local name of the new element
|
williamr@2
|
306 |
* @param aQName The qualified name of the new element
|
williamr@2
|
307 |
* @param aAttributes The attributes of the new element
|
williamr@2
|
308 |
*/
|
williamr@2
|
309 |
IMPORT_C virtual void ParseHeaderL(const RTagInfo& aElement,
|
williamr@2
|
310 |
const RAttributeArray& aAttributes);
|
williamr@2
|
311 |
|
williamr@2
|
312 |
// Functions from base classes
|
williamr@2
|
313 |
|
williamr@2
|
314 |
// From CSenFragmentBase
|
williamr@2
|
315 |
IMPORT_C virtual void OnStartElementL(const RTagInfo& aElement,
|
williamr@2
|
316 |
const RAttributeArray& aAttributes,
|
williamr@2
|
317 |
TInt aErrorCode);
|
williamr@2
|
318 |
|
williamr@2
|
319 |
IMPORT_C virtual void OnEndElementL(const RTagInfo& aElement,
|
williamr@2
|
320 |
TInt aErrorCode);
|
williamr@2
|
321 |
|
williamr@2
|
322 |
IMPORT_C virtual CSenFragmentBase* CreateBodyFragmentL(const TDesC8& aNsUri,
|
williamr@2
|
323 |
const TDesC8& aLocalName,
|
williamr@2
|
324 |
const TDesC8& aPrefix,
|
williamr@2
|
325 |
const RAttributeArray& aAttributes,
|
williamr@2
|
326 |
TXmlEngElement& aParent,
|
williamr@2
|
327 |
RSenDocument& aOwnerDocument);
|
williamr@2
|
328 |
|
williamr@2
|
329 |
protected: // Data
|
williamr@2
|
330 |
// Internal members, protected so that deriving classes have access to them.
|
williamr@2
|
331 |
CSenFragmentBase* ipBodyFragment;
|
williamr@2
|
332 |
CSenFragmentBase* ipHeaderFragment;
|
williamr@2
|
333 |
HBufC8* ipSoapAction;
|
williamr@2
|
334 |
TInt iTransactionId;
|
williamr@2
|
335 |
|
williamr@2
|
336 |
MSenProperties* ipProperties; // owned => safe upward cast is performed in de-alloc
|
williamr@2
|
337 |
MSenMessageContext* ipNotOwnedContext; // owned => safe upward cast is performed in de-alloc
|
williamr@2
|
338 |
|
williamr@2
|
339 |
TAny* ipReserved;
|
williamr@2
|
340 |
|
williamr@2
|
341 |
TBool iFault;
|
williamr@2
|
342 |
TDirection iDirection;
|
williamr@2
|
343 |
};
|
williamr@2
|
344 |
|
williamr@2
|
345 |
#endif // SEN_SOAP_ENVELOPE_H
|
williamr@2
|
346 |
|
williamr@2
|
347 |
// End of File
|
williamr@2
|
348 |
|
williamr@2
|
349 |
|
williamr@2
|
350 |
|