Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Examples  

SoapSerializer.h

00001 /*
00002  *   Copyright 2003-2004 The Apache Software Foundation.
00003  *
00004  *   Licensed under the Apache License, Version 2.0 (the "License");
00005  *   you may not use this file except in compliance with the License.
00006  *   You may obtain a copy of the License at
00007  *
00008  *       http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  *   Unless required by applicable law or agreed to in writing, software
00011  *   distributed under the License is distributed on an "AS IS" BASIS,
00012  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *   See the License for the specific language governing permissions and
00014  *   limitations under the License.
00015  */
00016 
00017 #if !defined(_SOAPSERIALIZER_H____OF_AXIS_INCLUDED_)
00018 #define _SOAPSERIALIZER_H____OF_AXIS_INCLUDED_
00019 
00020 #include "IHandlerSoapSerializer.h"
00021 #include "BasicTypeSerializer.h"
00022 #include "AxisTime.h"
00023 #include "Packet.h"
00024 #include "WSDDDefines.h"
00025 #include "SoapEnvVersions.h"
00026 #include <axis/AxisSoapException.h>
00027 
00028 class SoapEnvelope;
00029 class SoapHeader;
00030 class SoapMethod;
00031 class SoapBody;
00032 class SoapFault;
00033 class HeaderBlock;
00034 
00035 #include <map>
00036 using namespace std;
00037 
00048 class SoapSerializer : public IHandlerSoapSerializer
00049 {
00050     typedef struct
00051     {
00052         volatile unsigned char inuse;
00053         volatile char* buffer;
00054     } SerializeBuffers;
00055 private:
00056     int m_nCounter;
00057     AxisChar m_Buf[8];
00058     SoapEnvelope* m_pSoapEnvelope;    
00059     int m_iSoapVersion;
00060     /* Current Serialization Style */
00061     AXIS_BINDING_STYLE m_nStyle;
00062     /* Table that keeps all allocated buffers */
00063     volatile SerializeBuffers* m_pSZBuffers;
00064     /* Size of the initial buffer created.*/
00065     int m_nInitialBufferSize;
00066     /* Size of the m_SZBuffers array.*/
00067     int m_nMaxBuffersToCreate;
00068     /* Maximum size of the buffer that is being filled */
00069     int m_nCurrentBufferSize;
00070     /* How much charators has been filled to the currently selected buffer */
00071     int m_nFilledSize;
00072     /* Currently selected buffer index*/
00073     int m_nCurrentBufferIndex;
00074     /* Overall status of Serializer. If anything goes wrong this is not 
00075      * AXIS_SUCCESS 
00076      */
00077     int m_nStatus;
00078     /* Map that contains pairs of currently available namespaces and 
00079      * prefixes 
00080      */ 
00081     map<AxisXMLString, AxisXMLString> m_NsStack;
00082     /* Provider type of current service that uses this Serializer object */
00083     PROVIDERTYPE m_ProviderType;
00084 public:
00085 
00086 #ifdef UNIT_TESTING_ON
00087     int setOutputStreamForTesting(SOAPTransport* pStream);
00088 #endif
00089     int AXISCALL createSoapMethod(const AxisChar* sLocalName, 
00090         const AxisChar* sURI);
00091 
00092     int AXISCALL createSoapFault(const AxisChar* sLocalName, 
00093         const AxisChar* sURI);
00094 
00095 /*    IWrapperSoapSerializer& operator<<(const char* cSerialized); */
00096     IWrapperSoapSerializer& operator<<(const AxisChar* cSerialized);
00102     const AxisChar* AXISCALL getNamespacePrefix(const AxisChar* pNamespace);
00112     const AxisChar* AXISCALL getNamespacePrefix(const AxisChar* pNamespace,
00113         bool& blnIsNewPrefix);
00114     void AXISCALL removeNamespacePrefix(const AxisChar* pNamespace);
00115     int setSoapVersion(SOAP_VERSION);
00116     int init();
00117     int setOutputStream(SOAPTransport* pStream);
00118     void markEndOfStream();
00119     int setSoapMethod(SoapMethod* pSoapMethod);
00120     int setSoapFault(SoapFault* pSoapFault);
00121     int setSoapBody(SoapBody* pSoapBody);
00122     int setSoapHeader(SoapHeader* pSoapHeader);
00123     int setSoapEnvelope(SoapEnvelope* pSoapEnvelope);
00124     SoapSerializer();
00125     virtual ~SoapSerializer();
00126 
00127     /* for arrays of basic types */
00128     int AXISCALL addOutputBasicArrayParam(const Axis_Array* pArray, 
00129         XSDTYPE nType, const AxisChar* pName);
00130 
00131     /* for arrays of complex types */
00132     int AXISCALL addOutputCmplxArrayParam(const Axis_Array* pArray, 
00133         void* pSZFunct, void* pDelFunct, void* pSizeFunct, 
00134         const AxisChar* pName, const AxisChar* pNamespace);
00135 
00136     /* for complex types */
00137     int AXISCALL addOutputCmplxParam(void* pObject, void* pSZFunct, 
00138         void* pDelFunct, const AxisChar* pName, const AxisChar* pNamespace);
00139 
00140     int AXISCALL addFaultDetail(void* pObject, void* pSZFunct,
00141         void* pDelFunct, const AxisChar* pName, const AxisChar* pNamespace );
00142 
00143     int AXISCALL serializeCmplxArray(const Axis_Array* pArray, void* pSZFunct,
00144         void* pDelFunct, void* pSizeFunct, const AxisChar* pName, 
00145         const AxisChar* pNamespace);
00146 
00147     int AXISCALL serializeBasicArray(const Axis_Array* pArray, XSDTYPE nType, 
00148         const AxisChar* pName);
00149     /* following two functions are needed by serializer functions of complex 
00150      * types for RPC style web services 
00151      */
00152     void AXISCALL serializeStartElementOfType(const AxisChar* pName, 
00153         const AxisChar* pNamespace, const AxisChar* pPrefix);
00154     void AXISCALL serializeEndElementOfType(const AxisChar* pName);
00155     PROVIDERTYPE getCurrentProviderType() { return m_ProviderType;};
00156     void setCurrentProviderType(PROVIDERTYPE nType) { m_ProviderType = nType;};
00157 
00158 private:
00159     int sendSerializedBuffer();
00160     int setNextSerilizeBuffer();
00161     IArrayBean* makeArrayBean(XSDTYPE nType, void* pArray);
00162     IArrayBean* makeArrayBean(void* pObject, void* pSZFunct, void* pDelFunct, 
00163         void* pSizeFunct);
00164 
00165 public: /* Basic Type Serializing methods */
00166     int removeSoapHeader();
00167     int setHeaderBlock(HeaderBlock* pHeaderBlock);
00168     IHeaderBlock* createHeaderBlock();
00169     
00170 private:
00171     BasicTypeSerializer m_BTSZ;
00172     SOAPTransport* m_pOutputStream;
00173 public:
00174         IHeaderBlock* getHeaderBlock(const AxisChar* pcName, const AxisChar* pcNamespace);
00175         IHeaderBlock* getHeaderBlock();
00176         int setSOAPMethodAttribute(Attribute* pAttribute);
00177         SoapMethod* getSOAPMethod();
00178     IHeaderBlock* createHeaderBlock(AxisChar *pachLocalName,
00179         AxisChar *pachUri);
00180     /* to add a header block to the Serializer. Probably by a handler */
00181     int AXISCALL addHeaderBlock(IHeaderBlock* pBlk);
00182     int AXISCALL addOutputParam(const AxisChar* pchName, 
00183         void* pValue, XSDTYPE type);
00184     int AXISCALL serializeAsElement(const AxisChar* pchName, 
00185         void* pValue, XSDTYPE type);
00186     int AXISCALL serializeAsAttribute(const AxisChar* pName, 
00187         const AxisChar* pNamespace, void* pValue, XSDTYPE type);
00188     void AXISCALL serialize(const char* pFirst, ...);
00189     void setStyle(AXIS_BINDING_STYLE nStyle)
00190     { m_nStyle = nStyle; m_BTSZ.setStyle(nStyle);};
00191     AXIS_BINDING_STYLE getStyle(){return m_nStyle;};
00192     int AXISCALL setBodyAsHexBinary(xsd__hexBinary body);
00193     int AXISCALL setBodyAsBase64Binary(xsd__base64Binary body);
00194     const AxisChar* AXISCALL getBodyAsString();
00195         static void AXISCALL releaseBufferCallBack(const char* buffer,
00196         const void* bufferid);
00197         int addOutputAnyObject(AnyType* pAnyObject);
00198         int serializeAnyObject(AnyType* pAnyObject);
00199 };
00200 
00201 #endif 
00202 
00203 

Generated on Tue Jun 29 09:27:57 2004 for AxisC++ by doxygen1.2.18