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 <axis/SOAPTransport.h>
00022 
00023 #include "BasicTypeSerializer.h"
00024 #include "WSDDDefines.h"
00025 
00026 class SoapEnvelope;
00027 class SoapHeader;
00028 class SoapMethod;
00029 class SoapBody;
00030 class SoapFault;
00031 class HeaderBlock;
00032 class IArrayBean;
00033 
00044 class SoapSerializer : public IHandlerSoapSerializer
00045 {
00046     typedef struct
00047     {
00048         volatile unsigned char inuse;
00049         volatile char* buffer;
00050     } SerializeBuffers;
00051 private:
00052     int m_nCounter;
00053     AxisChar m_Buf[8];
00054     SoapEnvelope* m_pSoapEnvelope;    
00055     int m_iSoapVersion;
00056     /* Current Serialization Style */
00057     AXIS_BINDING_STYLE m_nStyle;
00058     /* Table that keeps all allocated buffers */
00059     volatile SerializeBuffers* m_pSZBuffers;
00060     /* Size of the initial buffer created.*/
00061     int m_nInitialBufferSize;
00062     /* Size of the m_SZBuffers array.*/
00063     int m_nMaxBuffersToCreate;
00064     /* Maximum size of the buffer that is being filled */
00065     int m_nCurrentBufferSize;
00066     /* How much charators has been filled to the currently selected buffer */
00067     int m_nFilledSize;
00068     /* Currently selected buffer index*/
00069     int m_nCurrentBufferIndex;
00070     /* Overall status of Serializer. If anything goes wrong this is not 
00071      * AXIS_SUCCESS 
00072      */
00073     int m_nStatus;
00074     /* Map that contains pairs of currently available namespaces and 
00075      * prefixes 
00076      */ 
00077     map<AxisXMLString, AxisXMLString> m_NsStack;
00078     /* Provider type of current service that uses this Serializer object */
00079     PROVIDERTYPE m_ProviderType;
00080 public:
00081 
00082 #ifdef UNIT_TESTING_ON
00083     int setOutputStreamForTesting(SOAPTransport* pStream);
00084 #endif
00085     int AXISCALL createSoapMethod(const AxisChar* sLocalName, 
00086         const AxisChar* sURI);
00087 
00088     int AXISCALL createSoapFault(const AxisChar* sLocalName, 
00089         const AxisChar* sURI, const AxisChar* sFaultCode,
00090         const AxisChar* sFaultString);
00091 
00092 /*    IWrapperSoapSerializer& operator<<(const char* cSerialized); */
00093     IWrapperSoapSerializer& operator<<(const AxisChar* cSerialized);
00099     const AxisChar* AXISCALL getNamespacePrefix(const AxisChar* pNamespace);
00109     const AxisChar* AXISCALL getNamespacePrefix(const AxisChar* pNamespace,
00110         bool& blnIsNewPrefix);
00111     void AXISCALL removeNamespacePrefix(const AxisChar* pNamespace);
00112     int setSoapVersion(SOAP_VERSION);
00113     int init();
00114     int setOutputStream(SOAPTransport* pStream);
00115     void markEndOfStream();
00116     int setSoapMethod(SoapMethod* pSoapMethod);
00117     int setSoapFault(SoapFault* pSoapFault);
00118     int setSoapBody(SoapBody* pSoapBody);
00119     int setSoapHeader(ISoapHeader* pSoapHeader);
00120     int setSoapEnvelope(SoapEnvelope* pSoapEnvelope);
00121     SoapSerializer();
00122     virtual ~SoapSerializer();
00123 
00124     /* for arrays of basic types */
00125     int AXISCALL addOutputBasicArrayParam(const Axis_Array* pArray, 
00126         XSDTYPE nType, const AxisChar* pName);
00127 
00128     /* for arrays of complex types */
00129     int AXISCALL addOutputCmplxArrayParam(const Axis_Array* pArray, 
00130         void* pSZFunct, void* pDelFunct, void* pSizeFunct, 
00131         const AxisChar* pName, const AxisChar* pNamespace);
00132 
00133     /* for complex types */
00134     int AXISCALL addOutputCmplxParam(void* pObject, void* pSZFunct, 
00135         void* pDelFunct, const AxisChar* pName, const AxisChar* pNamespace);
00136 
00137     int AXISCALL addFaultDetail(void* pObject, void* pSZFunct,
00138         void* pDelFunct, const AxisChar* pName, const AxisChar* pNamespace );
00139 
00140     int AXISCALL serializeCmplxArray(const Axis_Array* pArray, void* pSZFunct,
00141         void* pDelFunct, void* pSizeFunct, const AxisChar* pName, 
00142         const AxisChar* pNamespace);
00143 
00144     int AXISCALL serializeBasicArray(const Axis_Array* pArray, XSDTYPE nType, 
00145         const AxisChar* pName);
00146     /* following two functions are needed by serializer functions of complex 
00147      * types for RPC style web services 
00148      */
00149     void AXISCALL serializeStartElementOfType(const AxisChar* pName, 
00150         const AxisChar* pNamespace, const AxisChar* pPrefix);
00151     void AXISCALL serializeEndElementOfType(const AxisChar* pName);
00152     PROVIDERTYPE getCurrentProviderType() { return m_ProviderType;};
00153     void setCurrentProviderType(PROVIDERTYPE nType) { m_ProviderType = nType;};
00154 
00155 private:
00156     int sendSerializedBuffer();
00157     int setNextSerilizeBuffer();
00158     IArrayBean* makeArrayBean(XSDTYPE nType, void* pArray);
00159     IArrayBean* makeArrayBean(void* pObject, void* pSZFunct, void* pDelFunct, 
00160         void* pSizeFunct);
00161 
00162 public: /* Basic Type Serializing methods */
00163     int removeSoapHeader();
00164     int setHeaderBlock(HeaderBlock* pHeaderBlock);
00165     IHeaderBlock* createHeaderBlock();
00166     
00167 private:
00168     BasicTypeSerializer m_BTSZ;
00169     SOAPTransport* m_pOutputStream;
00170 public:
00171         IHeaderBlock* getHeaderBlock(const AxisChar* pcName, const AxisChar* pcNamespace);
00172         IHeaderBlock* getHeaderBlock();
00173         int setSOAPMethodAttribute(Attribute* pAttribute);
00174         SoapMethod* getSOAPMethod();
00175     IHeaderBlock* createHeaderBlock(AxisChar *pachLocalName,
00176         AxisChar *pachUri);
00177     /* to add a header block to the Serializer. Probably by a handler */
00178     int AXISCALL addHeaderBlock(IHeaderBlock* pBlk);
00179     int AXISCALL addOutputParam(const AxisChar* pchName, 
00180         void* pValue, XSDTYPE type);
00181     int AXISCALL serializeAsElement(const AxisChar* pchName, 
00182         void* pValue, XSDTYPE type);
00183     int AXISCALL serializeAsAttribute(const AxisChar* pName, 
00184         const AxisChar* pNamespace, void* pValue, XSDTYPE type);
00185     void AXISCALL serialize(const char* pFirst, ...);
00186     void setStyle(AXIS_BINDING_STYLE nStyle)
00187     { m_nStyle = nStyle; m_BTSZ.setStyle(nStyle);};
00188     AXIS_BINDING_STYLE getStyle(){return m_nStyle;};
00189     int AXISCALL setBodyAsHexBinary(xsd__hexBinary body);
00190     int AXISCALL setBodyAsBase64Binary(xsd__base64Binary body);
00191     const AxisChar* AXISCALL getBodyAsString();
00192         static void AXISCALL releaseBufferCallBack(const char* buffer,
00193         const void* bufferid);
00194         int addOutputAnyObject(AnyType* pAnyObject);
00195         int serializeAnyObject(AnyType* pAnyObject);
00196 };
00197 
00198 #endif 
00199 
00200 

Generated on Fri Jul 9 13:18:29 2004 for AxisC++ by doxygen1.2.18