ISerializerFactoryConfig::RootFirst Property

[propget] HRESULT RootFirst([out, retval] VARIANT_BOOL * rootFirst);
[propput] HRESULT RootFirst([in] VARIANT_BOOL rootFirst);

When serializing to XML, the serializer engine will place all values that could be multi-references as independent elements [this save's it from having to traverse the values to serialize twice]. The SOAP spec doesn't dictate the order between the real serialization root and the independent roots. The RootsFirst property allows you to specify if you want the main serialization root first, or the independent elements first. Many servers incorrectly assume that the first child of the Body element is the main serialization root [this is wrong, they should look at the root attribute], and for that reason it defaults to true [i.e. the main serialization root is first]. However if you are dealing with a streaming based parser, it is more efficient to have as many independent roots de-serialized first [as the deserializer doesn't have to go back and fixup things its partially de-serialized].

 

Return Values

a VARIANT_BOOL containing the current RootsFirst property value

 

Sample Code

dim e, n
set e = CreateObject("pocketSOAP.Envelope.2")
e.SetMethod "echoStruct", "http://soapinterop.org/"
set n = e.Parameters.Create ("inputStruct", "","", "SOAPStruct", "http://soapinterop.org/xsd")
n.Nodes.Create "varInt", 42
n.Nodes.Create "varFloat", 42.42
n.Nodes.Create "varString", "Zaphod"

' first off, the default, the serialization root is first
wscript.echo "RootFirst" & vbCRLF & e.serialize

e.SerializerFactory.RootFirst = false
wscript.echo vbCRLF & "RootLast" & vbCRLF & e.serialize


' this generates
RootFirst
<S:Envelope
        S:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
        xmlns:S='http://schemas.xmlsoap.org/soap/envelope/'
        xmlns:E='http://schemas.xmlsoap.org/soap/encoding/'
        xmlns:a='http://soapinterop.org/'
        xmlns:b='http://soapinterop.org/xsd'
        xmlns:c='http://www.w3.org/2001/XMLSchema-instance'
        xmlns:d='http://www.w3.org/2001/XMLSchema'>
<S:Body><a:echoStruct><inputStruct href='#a'/>
</a:echoStruct>
<b:SOAPStruct E:root='0' id='a' c:type='b:SOAPStruct'><varInt c:type='d:short'>42</varInt>
<varFloat c:type='d:double'>42.42</varFloat>
<varString c:type='d:string'>Zaphod</varString>
</b:SOAPStruct>
</S:Body></S:Envelope>

RootLast
<S:Envelope
        S:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
        xmlns:S='http://schemas.xmlsoap.org/soap/envelope/'
        xmlns:E='http://schemas.xmlsoap.org/soap/encoding/'
        xmlns:a='http://soapinterop.org/'
        xmlns:b='http://soapinterop.org/xsd'
        xmlns:c='http://www.w3.org/2001/XMLSchema-instance'
        xmlns:d='http://www.w3.org/2001/XMLSchema'>
<S:Body><b:SOAPStruct E:root='0' id='a' c:type='b:SOAPStruct'><varInt c:type='d:short'>42</varInt>
<varFloat c:type='d:double'>42.42</varFloat>
<varString c:type='d:string'>Zaphod</varString>
</b:SOAPStruct>
<a:echoStruct><inputStruct href='#a'/>
</a:echoStruct>
</S:Body></S:Envelope>

 

See Also

The ISerializerFactoryConfig Interface | 

 

 

Copyright

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