ITypesInit::Initialize Method

HRESULT Initialize([in] BSTR xmlType, [in] BSTR xmlTypeNamespace, [in] VARIANT comType);

Once the serializerFactory has created the serializer, it calls this passing the type information it used to select this [de]serializer. The [de]serializer can later use this information as needed, e.g. to write out an xsi:type='ns:type' attribute during serialization.

 

Parameters

xmlType
BSTR, [in]: The name of the XmlType
xmlTypeNamespace
BSTR, [in]: The namespace of the XmlType
comType
VARIANT, [in]: The COM type, the exact meaning of the COM type for deserialization is dependent upon the deserializer, typically it is either an integer value represent the VARTYPE [for simple types], or it is a stringified IID [for objects]

 

Return Values

Raise an error here if either the Xml Type or COM type is unexpected. This will stop the serialization process, and bubble the error to the calling code.

 

Sample Code

Visual Basic Class File

Private Const NS = "http://auth.example.org/2001/01/"

Implements ISoapSerializer
Implements ITypesInit

Private m_type As String
Private m_ns As String

Private Sub ITypesInit_Initialize(ByVal XmlType As String, ByVal XmlTypeNamespace As String, ByVal ComType As Variant)
    m_type = XmlType
    m_ns = XmlTypeNamespace
End Sub

Private Sub ISoapSerializer_Serialize(V As Variant, _
                                        ByVal ctx As PocketSOAP.ISerializerContext, _
                                        ByVal dest As PocketSOAP.ISerializerOutput)
    Dim sf As CoSerializerFactory
    Set sf = ctx.SerializerFactory
    dest.QNameAttribute "type", sf.XsiForPrimaryNS, m_type, m_ns
    dest.SerializeValue V.Key, "key", NS
    dest.SerializeValue V.Type, "type", NS
End Sub

 

See Also

The ITypesInit Interface | 

 

 

Copyright

Copyright © Simon Fell, 2000-2004. All rights reserved.