SOAP Headers

PocketSOAP supports both send and receiving SOAP Header, these work in exactly the same way as elements within the Body, except that they are accessed through the Headers property on the Envelope rather than the Parameters property. In addition, you can set the various header attributes including actor, mustUnderstand through the normal Node object.

Sample

This sample sets a simple header containing authentication information.
dim e, h
set e = CreateObject("pocketSOAP.Envelope.2")
e.SetMethod "DoStuff", "http://soap.example.org/"

set h = e.Headers.Create ("Authentication", empty, "http://soap.example.org/authentication/2001/01/")
h.Nodes.Create "Username", "user@example.org"
h.Nodes.Create "MD5", "9b3e64e326537b4e8c0ff19e953f9673"

wscript.echo e.serialize
This generates the following SOAP message
<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://soap.example.org/authentication/2001/01/'
        xmlns:b='http://www.w3.org/2001/XMLSchema-instance'
        xmlns:c='http://www.w3.org/2001/XMLSchema'
        xmlns:d='http://soap.example.org/'>
<S:Header>
<a:Authentication>
<Username b:type='c:string'>user@example.org</Username>
<MD5 b:type='c:string'>9b3e64e326537b4e8c0ff19e953f9673</MD5>
</a:Authentication>
</S:Header>
<S:Body><d:DoStuff></d:DoStuff>
</S:Body></S:Envelope>
You can set the actor and mustUnderstand attributes through the actor and mustUnderstand properties on the node, e.g.
dim e, h
set e = CreateObject("pocketSOAP.Envelope.2")
e.SetMethod "DoStuff", "http://soap.example.org/"

set h = e.Headers.Create ("Authentication", empty, "http://soap.example.org/authentication/2001/01/")
h.mustUnderstand = true 
h.actor = "http://soap.example/org/authentication/"
h.Nodes.Create "Username", "user@example.org"
h.Nodes.Create "MD5", "9b3e64e326537b4e8c0ff19e953f9673"

wscript.echo e.serialize
This generates the following SOAP message
<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://soap.example.org/authentication/2001/01/'
        xmlns:b='http://www.w3.org/2001/XMLSchema-instance'
        xmlns:c='http://www.w3.org/2001/XMLSchema'
        xmlns:d='http://soap.example.org/'>
<S:Header>
<a:Authentication S:mustUnderstand='1' S:actor='http://soap.example/org/authentication/'>
<Username b:type='c:string'>user@example.org</Username>
<MD5 b:type='c:string'>9b3e64e326537b4e8c0ff19e953f9673</MD5>
</a:Authentication>
</S:Header>
<S:Body><d:DoStuff></d:DoStuff>
</S:Body></S:Envelope>
All the standard serialization process applies to headers, so you can write custom serializer for handling header parts.


Copyright

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