ISoapSerializer::Serialize Method

HRESULT Serialize([in] VARIANT * val, [in] ISerializerContext * ctx, [in] ISerializerOutput * dest);

Once the serializer engine has created a particular serializer it will call the serialize method to have it convert the COM value into a SOAP/XML representation. At this point serializer engine has already creating the start of the element, along with its correct name & namespace prefix. If you need to add any attributes to the element call ISerializerOutput::Attribute or ISerializerOutput::QNameAttribute. When the Serialize method returns, the serializer engine will automatically add the closing element.

 

Parameters

val
VARIANT *, [in]: The value to serialize
ctx
ISerializerContext *, [in]: An interface pointer to the current serialization context
dest
ISerializerOutput *, [in]: The serialization destination, the serializer should make calls against this interface to generate the serialized representation

 

Return Values

If the serializer returns an error from this method, then the serialization is stopped, and the error is propagated to the caller.

 

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
    
    ' write out the xsi:type='xsd:foo' attribute
    dest.QNameAttribute "type", sf.XsiForPrimaryNS, m_type, m_ns
    
    ' write out a child element {http://auth.example.org/2001/01/}key with the value V.Key
    dest.SerializeValue V.Key, "key", NS
    
    ' write out a child element {http://auth.example.org/2001/01/}type with the value v.Type
    dest.SerializeValue V.Type, "type", NS
End Sub

 

See Also

The ISoapSerializer Interface | 

 

 

Copyright

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